How to correct matrix dimension disagree error
Mostrar comentarios más antiguos
figure
clear;
clc;
v = 1.0;
n=[0.00 0.10 0.12 0.18];
u = linspace(0,2);
%%
for i = 1:length(n)
sigma = ((1i.*u-1-v.^2)./(v.^2-u.^2 +1-2i.*u)).*(1./(v.^2 +1));
sigmapri = n*((1i.*u-1-v.^2)./((1+n).^2 +v.^2).*(v.^2-u.^2 +1-2i.*u)).*(1-(v./(v.^2 +1)));
w = sigma + sigmapri;
plot(u, real(w))
end
%%
xlabel('\omega*\tau')
ylabel('\sigma(\omega)/\sigma_o')
4 comentarios
David Hill
el 28 de Mzo. de 2020
What is 1i and 2i? You will need to make the size of n and the size of u the same. Can n be linspace(0,.18)?
the cyclist
el 28 de Mzo. de 2020
1i and 2i are just the imaginary constants sqrt(-1) and 2*sqrt(-1), so should not be problematic here.
Samuel Suakye
el 28 de Mzo. de 2020
Samuel Suakye
el 28 de Mzo. de 2020
Respuesta aceptada
Más respuestas (1)
the cyclist
el 28 de Mzo. de 2020
You are effectively trying to do this operation in your code:
n * u
where n is a 1x4 matrix, and u is a 1x100 matrix.
That won't work, as either a matrix multiplication or as an element-by-element multiplication. What do you expect from that?
1 comentario
Samuel Suakye
el 28 de Mzo. de 2020
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
