How to find matrix dimensions while using * operator ?
古いコメントを表示
i was trying to plot this equation Nw=10(50+(7.5(w)1/2))+20log10(f)40log10(f+0.4))Nwoff, i got the below error.
f=200:100:200000;
Nwoff=1:10;
for n=Nwoff
Nw=10.^((50+(7.5*1/2))+20*log10(f).^40*log10(f+0.4))*n;
plot(f,Nw)
hold on
end
Error using * Inner matrix dimensions must agree.
thank you in advance.
回答 (1 件)
Roger Stafford
2017 年 2 月 16 日
Your error lies in the expression
20*log10(f).^40*log10(f+0.4)
Here you are using matrix multiplication on two thousand-element row vectors, and that is a no-no. Undoubtedly you meant
20*log10(f).^40.*log10(f+0.4)
with a dot before the asterisk sign.
Your plot will be filled with ten different thousand-point curves with this correction.
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!