# Creating multiple sine wave data

Hi I need some help creating multiple sine wave profiles and storing them in arrays. I just need data to test another function and sine data is the most useful. It would be helpful if I could also randomize the sinewave signal a little bit by adding a random number to each element.

Pseudocode

begin
Create sine waves(I don’t know how to do this yet)
**I tried a for loop and it didn’t exactly work

sinewave1 = [0, 0.2, 0.6, 1, 0.6 ,0.2, 0, - 0.2, -0.6, -1,- 0.6 ,-0.2,0]
sinewave2 = [0, 0.2, 0.6, 1, 0.6 ,0.2, 0, - 0.2, -0.6, -1,- 0.6 ,-0.2,0]
sinewave3 = [0, 0.2, 0.6, 1, 0.6 ,0.2, 0, - 0.2, -0.6, -1,- 0.6 ,-0.2,0]

Transpose the sine wave profiles above so instead of [13,1] it is [1,13].
concatenate the 3 arrays
add random number to each element

end

Look into `cat()`, `transpose()` and `push!()`.

For example, here is one period of a sine wave + 1% noise:

``````x = range(0, 2π, length=100)
y = @. sin(x) + 0.01 * randn()
``````
3 Likes

It might be useful to link here your other post explaining the (non-trivial) broadcasting of `rand()`.

1 Like