How to find matrix dimensions while using * operator ?
1 view (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Roger Stafford
on 16 Feb 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.
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!