MATLAB: What is the error of the plot

plot

if true
% code
endm5=1.78
c6=0.00036
c7=0.02
c8=0.00004
c9=0.1
k6=167.00
k8=623.00
F = 80
for w= 20:100:1000
x5(end+1) = F/(sqrt(((k6+k8)-(m5*w))^2+((c6+c7+c8+c9)*w)^2))
end
plot (w,x5)
I can't see why the plot is wrong. Could please somebody help?

Best Answer

You're plotting x5 vs the LAST value of w (a scalar that you used as the loop index), not the whole array. Try reassigning w to the whole array before plotting:
w = 20 : 100 : 1000;
plot(w, x5)