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."

回答(2 个)

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 2016-10-25
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.

类别

帮助中心File Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by