Matrix dimension must agree

조회 수: 1 (최근 30일)
Muhammad Fauzan
Muhammad Fauzan 2020년 11월 17일
답변: Ameer Hamza 2020년 11월 17일
w = [0:1:500]*pi/500;
X = exp(j*w)./(exp(j.*w) - 0.5.*ones(1,500));
magx = abs(X); angX = angel(X);
subplot(2,2,1); plot(w/pi,magX); grid
xlabel('frequency in pi units'); title('Magnitude Part'); ylabel('Magnitude')
subplot(2,2,3); plot(w/pi,angX); grid
xlabel('frequency in pi units'); title('Angel Part'); ylabel('Radians')
subplot(2,2,2); plot(w/pi,realX); grid
xlabel('frequency in pi units'); title('Real Part'); ylabel('Real')
subplot(2,2,4); plot(w/pi,imagX); grid
xlabel('frequency in pi units'); title('Imaginary Part'); ylabel('Imaginary')
ERROR:
Error using -
Matrix dimensions must agree.

답변 (2개)

Alan Stevens
Alan Stevens 2020년 11월 17일
w is size 1x501 not 1x500.
  댓글 수: 1
Muhammad Fauzan
Muhammad Fauzan 2020년 11월 17일
Error Just in line 2

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


Ameer Hamza
Ameer Hamza 2020년 11월 17일
There are several syntax error in your code. Compare following with your code to see the mistakes.
w = (0:1:500)*pi/500;
X = exp(1j*w)./(exp(1j.*w) - 0.5.*ones(1,501));
magx = abs(X); angX = angle(X);
realX = real(X); imagX = imag(X);
subplot(2,2,1); plot(w/pi,magx); grid
xlabel('frequency in pi units'); title('Magnitude Part'); ylabel('Magnitude')
subplot(2,2,3); plot(w/pi,angX); grid
xlabel('frequency in pi units'); title('Angel Part'); ylabel('Radians')
subplot(2,2,2); plot(w/pi,realX); grid
xlabel('frequency in pi units'); title('Real Part'); ylabel('Real')
subplot(2,2,4); plot(w/pi,imagX); grid
xlabel('frequency in pi units'); title('Imaginary Part'); ylabel('Imaginary')

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by