How to correct matrix dimension disagree error
Ältere Kommentare anzeigen
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 Kommentare
David Hill
am 28 Mär. 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
am 28 Mär. 2020
1i and 2i are just the imaginary constants sqrt(-1) and 2*sqrt(-1), so should not be problematic here.
Samuel Suakye
am 28 Mär. 2020
Samuel Suakye
am 28 Mär. 2020
Akzeptierte Antwort
Weitere Antworten (1)
the cyclist
am 28 Mär. 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 Kommentar
Samuel Suakye
am 28 Mär. 2020
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
