FaithInStem
FaithInStem

Reputation: 11

Invalid data argument when using plot

I have a problem with the following MATLAB code:

E=1.15*10^5; 
h=0.35; 
b=50; 
l=75; 
i0=(b*h^3)/12;
f=0:1:10; 
P=[0 0.1 0.2 0.3 0.3 0.4 0.6 0.7 0.8 1.1 1.4];
Pt=(E*2*10^5*f)/l^3;

plot(f, P,'k','LineWidth', 2, f, Pt, '-.k', 'LineWidth', 2); grid; 

xlabel('Sageata f[mm]'); 
ylabel('Forta P[N]'); 
legend('P',  'P_t'); 
title('Caracteristica arcului triunghiular'); 

Error using plot

Invalid first data argument

First of all, what is k and -k and why my is plot not working without them? Secondly why do I only have one line?

Upvotes: 0

Views: 2850

Answers (1)

Ander Biguri
Ander Biguri

Reputation: 35525

If you want tight control of line parameters, its much better to just separate each line you want to plot in a separate plot call.

hold on
plot(f, P,'k','LineWidth', 2)
plot(f, Pt, '-.k', 'LineWidth', 2); 
grid; 
hold off

Upvotes: 1

Related Questions