Inner matrix dimensions must agree?

1 Ansicht (letzte 30 Tage)
Steven
Steven am 2 Jul. 2014
Beantwortet: Joseph Cheng am 2 Jul. 2014
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.

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 2 Jul. 2014
Bearbeitet: Azzi Abdelmalek am 2 Jul. 2014
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);

Joseph Cheng
Joseph Cheng am 2 Jul. 2014
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)].

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by