I do not understand this error message

3 ビュー (過去 30 日間)
mandy
mandy 2015 年 4 月 29 日
回答済み: Ken Atwell 2015 年 4 月 29 日
Hi I am trying to plot something in matlab and it keeps coming up with the error (* inner matrix dimensions must agree) for line 15 which is the v1= line. Can someone explain why this is and show how I can fix it. Thanks clear all A=1; To=4; t=-To:To/100:To; wo=2*pi/To;
U1=0; v1=0;
a0=0; for n=1:2:19 BN1=(4/(pi*n)) BN2=(n*pi)/2 v1=(BN1*sin(wo*n*t)*cos(wo*n*t)); end
plot(t,a0+v1) axis ([-0.2 0.2 -15 15]) grid

回答 (1 件)

Ken Atwell
Ken Atwell 2015 年 4 月 29 日
MATLAB is trying to preform matrix multiplication when I think you want element-by-element multiplication instead. Replace * (asterisk) with .* (dot-asterisk) throughout and you should be all set.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by