How to find matrix dimensions while using * operator ?
Afficher commentaires plus anciens
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.
Réponses (1)
Roger Stafford
le 16 Fév 2017
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.
Catégories
En savoir plus sur Line Plots 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!