필터 지우기
필터 지우기

One value not being displayed?

조회 수: 4 (최근 30일)
Annalise
Annalise 2015년 3월 21일
댓글: Chad Greene 2015년 3월 21일
Hello. I was wondering why one of my values isn't being displayed?
The value of '1' in the first graph (Magnitude Coefficients).
Code:
n_1 = 3:4:20;
n_2 = 0:2:20;
n_3 = 1:4:20;
s1 = n_3;
s2 = n_2==0;
s3 = n_1;
f(s1) = 4./(pi*s1).*sin(s1*pi/2);
f(s2) = 0;
f(s3) = -4./(pi*s3).*sin(s3*pi/2);
theta(n_3) = 0;
theta(n_1) = -pi;
subplot (2,1,1); stem(n_3, f(s1), 'p')
hold on
subplot (2,1,1); stem(n_1, f(s3), 'b'); ylabel('c_n'); xlabel('n'); title ('Magnitude Coefficients')
subplot (2,1,2); stem (n_3, theta(n_3), 'm')
hold on
subplot (2,1,2) ; stem (n_1, theta(n_1), 'g'); ylabel('\theta(n) [rad]'); xlabel('n') ; title ('Phase Coefficients')
Please and thank you.

채택된 답변

Chad Greene
Chad Greene 2015년 3월 21일
You've overwritten f(1) when you set f(s2)=0; Replace your first stem line with the values directly:
stem(n_3, 4./(pi*s1).*sin(s1*pi/2), 'p')
  댓글 수: 2
Annalise
Annalise 2015년 3월 21일
That worked... thank you ^^ I repositioned the values, so that f(s2) is taken in first, and it came out right.
Chad Greene
Chad Greene 2015년 3월 21일
Great!

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

추가 답변 (1개)

Image Analyst
Image Analyst 2015년 3월 21일
It is being displayed. f(1) is zero, and there is a marker at y=0 for the x=1 index.
  댓글 수: 1
Annalise
Annalise 2015년 3월 21일
Yeah, but it wasn't the value I was supposed to get ^^ It was supposed to be x(1) = 1.27. Thank you though! ^^

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

카테고리

Help CenterFile Exchange에서 Thermodynamics & Statistical Physics에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by