Matrix dimension must agree

1 visualización (últimos 30 días)
Muhammad Fauzan
Muhammad Fauzan el 17 de Nov. de 2020
Respondida: Ameer Hamza el 17 de Nov. de 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.

Respuestas (2)

Alan Stevens
Alan Stevens el 17 de Nov. de 2020
w is size 1x501 not 1x500.

Ameer Hamza
Ameer Hamza el 17 de Nov. de 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')

Etiquetas

Productos


Versión

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by