Error using / Matrix dimensions must agree.

I wanna draw a abs graph of a function that is 1/2j*( 1 / ( 1-exp( jTs(10-w) ) ) - 1/( 1-exp( -jTs( 10+w ) ) ) ) ) in frequency domain, and my code is below :
>> w=1:0.01:100;
>> y=abs(1/complex(0,2)*( 1/(1-exp(complex(0,-Ts*w))*exp(complex(0,10*Ts)))-1/(1-exp(complex(0,-
Ts*w))*exp(0,-10*Ts))))
Error using /
Matrix dimensions must agree.
>> figure(1);subplot(1,1,1);plot(w,y);
Undefined function or variable 'y'.
How can I solve the error below "Error using / Matrix dimensions must agree."

Réponses (2)

James Tursa
James Tursa le 25 Oct 2016
Modifié(e) : James Tursa le 25 Oct 2016
Use element-wise operators .* and ./ instead of matrix operators * and /
y=abs(1/complex(0,2)*( 1./(1-exp(complex(0,-Ts*w)).*exp(complex(0,10*Ts)))-1./(1-exp(complex(0,-Ts*w)).*exp(0,-10*Ts))))
KSSV
KSSV le 25 Oct 2016

0 votes

You are using w a vector, you have to use matrix element by element multiplication.. check your y part again and use ./ and .* where ever required. check matrix element wise operations.

Catégories

En savoir plus sur Operators and Elementary Operations 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!

Translated by