getting right t-value for sin wave
Show older comments
hey everyone, i have this problem that involves one part, i know how to do the problem just alittle confused about this part and hope you guys can help me out,
Generate a sine wave
y(t)=sin(2*pi*f*t+7*a)
and the problem asks to generate random value for a by using randn
this is what i got but cannot seem to get the right (t) to get the sin wave, how do i determine that?
t=??
f=10;
a=randn(1,length(t));
y=sin(2*pi*f*t+(7*a));
plot(t,y)thnx alot
3 Comments
Andrew Newell
on 4 Mar 2011
What do you mean by "get the sin wave"?
gedaa
on 4 Mar 2011
Walter Roberson
on 4 Mar 2011
The upper bound on your t should be an integer if you want a whole number of periods.
Answers (1)
Paulo Silva
on 4 Mar 2011
ok now I got it, if the objective is to add noise to a sine wave you are doing it the wrong way.
t=0:0.001:2
f=10;
a=randn(1,length(t));
y=a/10+sin(2*pi*f*t);
plot(t,y)
if the objective is to select a random phase than
t=0:0.001:2
f=10;
a=randn*2*pi; %something ?!
y=sin(2*pi*f*t+7*a);
plot(t,y)
4 Comments
gedaa
on 4 Mar 2011
Paulo Silva
on 4 Mar 2011
7*a is where the phase is, is that what is asked for?
gedaa
on 4 Mar 2011
gedaa
on 4 Mar 2011
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!