How to correct matrix dimension disagree error
이전 댓글 표시
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
David Hill
2020년 3월 28일
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
2020년 3월 28일
1i and 2i are just the imaginary constants sqrt(-1) and 2*sqrt(-1), so should not be problematic here.
Samuel Suakye
2020년 3월 28일
Samuel Suakye
2020년 3월 28일
채택된 답변
추가 답변 (1개)
the cyclist
2020년 3월 28일
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?
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
