How to correct matrix dimension disagree error
Afficher commentaires plus anciens
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 commentaires
David Hill
le 28 Mar 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
le 28 Mar 2020
1i and 2i are just the imaginary constants sqrt(-1) and 2*sqrt(-1), so should not be problematic here.
Samuel Suakye
le 28 Mar 2020
Samuel Suakye
le 28 Mar 2020
Réponse acceptée
Plus de réponses (1)
the cyclist
le 28 Mar 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 commentaire
Samuel Suakye
le 28 Mar 2020
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
