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 个)

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 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by