Matrix dimension must agree

1 vue (au cours des 30 derniers jours)
Muhammad Fauzan
Muhammad Fauzan le 17 Nov 2020
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.

Réponses (2)

Alan Stevens
Alan Stevens le 17 Nov 2020
w is size 1x501 not 1x500.
  1 commentaire
Muhammad Fauzan
Muhammad Fauzan le 17 Nov 2020
Error Just in line 2

Connectez-vous pour commenter.


Ameer Hamza
Ameer Hamza le 17 Nov 2020
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')

Produits


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by