Simple MATLAB (noob) question

조회 수: 2 (최근 30일)
Big Meech
Big Meech 2013년 4월 26일
Hello,
I not a frequent user to this program and I'm running into a little problem regarding graphing a function.
First I input this: x = 0:pi/15:4*pi
so that I can develop a range of the x values next I enter: y = (2*cos(60*x))
but it all comes out equaling two, when it shouldn't. I don't know where I'm going wrong. Help would be appreciated.

채택된 답변

Wayne King
Wayne King 2013년 4월 26일
편집: Wayne King 2013년 4월 26일
The way you set your x vector and then multiply by 60, you have increments of 4*pi (60*(pi/15)). Since you evaulate the cosine of angles that are multiples of 4*pi, those answers are all equal to 1 of course,then you multiply each by two.
What are you actually trying to do? Do you want your frequency to be 60 Hz or 60 radians per sample?
I'll assume 60 radians/sample for the moment.
x = 0:0.001:2*pi;
y = 2*cos(60*x);
plot(x,y)
If you want 60 cycles per second
x = 0:0.001:2;
y = 2*cos(2*pi*60*x);
plot(x,y)
  댓글 수: 1
Big Meech
Big Meech 2013년 4월 26일
Hello,
What I'm essentially trying to do is graph the function 2.0*cos(60x) in MATLAB like this: http://www.wolframalpha.com/input/?i=2*cos%2860x%29+graph+from+0+to+3pi
Would I first have to define the 60 in my x vector? I think I know what I have to do now.
Regards

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by