getting right t-value for sin wave

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

Andrew Newell
Andrew Newell 2011년 3월 4일
What do you mean by "get the sin wave"?
gedaa
gedaa 2011년 3월 4일
when i try different ranges for t, the wave doesn't look like a sin wave, it looks very distorted, like for example:
t=0:0.001:0.5;
Walter Roberson
Walter Roberson 2011년 3월 4일
The upper bound on your t should be an integer if you want a whole number of periods.

댓글을 달려면 로그인하십시오.

답변 (1개)

Paulo Silva
Paulo Silva 2011년 3월 4일

0 개 추천

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

gedaa
gedaa 2011년 3월 4일
but you changed the equation they're asking for, they want this wave created:
y(t)=sin(2*pi*f*t+7*a)
Paulo Silva
Paulo Silva 2011년 3월 4일
7*a is where the phase is, is that what is asked for?
gedaa
gedaa 2011년 3월 4일
i think the 2nd part you have makes sense, what i meant by 7*a is that it's part of the problem, i cannot take it out
gedaa
gedaa 2011년 3월 4일
the objective to the problem is actually both, first find randn for a, and then generating noise and then adding it to the sin wav

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2011년 3월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by