Sinusoidal signal with frequency

Hello ,
how can I generate a vector obtained by sampling a sinusoid of frequency f =1/T in the interval [0, T)?
Then I have to add to z a gaussian noise with zero mean and 0.15 standard deviation.
The values of N and f are free.
I wrote this code, but I am not sure.
t = (0:0.1:10)'; % interval [0,T)
f= 1/10; % frequency f = 1/T
z = sin(2*pi*f*t); %sinusoidal signal
plot(t,z); hold('on')
y = z + 0.15*randn(size(t)); %add gaussian noise with zero mean and 0.15 standard deviation
plot(t,y)

5 commentaires

Jan
Jan le 16 Déc 2022
This sounds like a homework question. As usual: Please post, what you have tried so far and ask a specific question. The forum will not solve your homework.
Jan
Jan le 16 Déc 2022
@Giuli: This looks fine.
Giuli
Giuli le 16 Déc 2022
Thank you
I have to define N?
Jan
Jan le 16 Déc 2022
Modifié(e) : Jan le 16 Déc 2022
If you want to define N, you can replace
t = (0:0.1:10)'
by
n = 100;
t = linspace(0, 10, n);
Maybe you want to remove the last element to get "[0,T)", but this is a little bit strange. [0,T] should be sufficient.
You implicitly defined N using the colon opertator do create the vector t. If you want to use N explicitly you can replace your statement with
N = 100;
t = linspace(0,10,N);

Connectez-vous pour commenter.

Réponses (0)

Question posée :

le 16 Déc 2022

Modifié(e) :

Jan
le 16 Déc 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by