Inner matrix dimensions must agree?
1 次查看(过去 30 天)
显示 更早的评论
I am trying to graph the magnitude and phase of this equation, and I keep getting that error.
I am a matlab newbie, no clue what's wrong at all.
%USER
w = [-25:25]*pi/25;
T = [-25:25];
X = -(2*1i*exp(-(1/2)*1i*T*w)*(-1+exp((1i* T* w)/2))*(-2+T))/(T*w);
magX = abs(X); phaX = angle(X);
In case it helps here is the function I am trying to graph in a more readable form.
0 个评论
回答(2 个)
Azzi Abdelmalek
2014-7-2
编辑:Azzi Abdelmalek
2014-7-2
When you multiply or divide two vectors, element by element, you need to add a dot (.) before your operator, in your case: .* and ./
w = [-25:25]*pi/25;
T = [-25:25];
X = -(2*1i*exp(-(1/2)*1i*T.*w).*(-1+exp((1i* T.* w)/2)).*(-2+T))./(T.*w);
0 个评论
Joseph Cheng
2014-7-2
What is happening is that you're performing matrix multiplication in your X = equation. which isn't what you want to do here. you need to perform the Element by element multiplication that Azzi has shown. this is performed by the '.*' which means for each element of w it will be multiplied by the same element in T. such that w.*T = [w(1)*T(1) w(2)*T(2) .... w(n)*T(n)].
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!