Reputation: 616
I'm struggling to plot multiple functions on one figure.
Here is the code that I have:
syms t a;
a=0.9514;
F1=0.5*sqrt(3*t^2);
F2=-0.28375*t^2+1.155*a*(t-a)+1;
F3=1;
E1=diff(F1,t);
E2=diff(F2,t);
E3=diff(F3,t);
I want to plot E1, E2 and E3, each only within a certain range, to make a "composite" line.
I've tried plotting with ezplot
but that only plots the last one.
plot
and fplot
give errors.
ezplot((3^(1/2)*t)/(2*(t^2)^(1/2)),[0,0.5*a])
hold on
ezplot((231*a)/200 - (231*t)/400,[0.5*a,2*a])
hold on
ezplot(0,[2*a,2.5*a])
(E3=0)
How can I get the functions to plot all at once?
Upvotes: 1
Views: 181
Reputation: 13216
I would suggest using a range of numbers for t
instead of symbols,
a=0.9514;
t1 = linspace(0.,0.5*a,1000);
t2 = linspace(0.5*a,2*a,1000);
t3 = linspace(2*a,2.5*a,1000);
F1=0.5*sqrt(3*t1.^2);
F2=-0.28375*t2.^2+1.155*a*(t2-a)+1;
F3=ones(size(t3));
E1=diff(F1)./diff(t1);
E2=diff(F2)./diff(t2);
E3=diff(F3)./diff(t3);
plot(t1(1:end-1), E1)
hold all
plot(t2(1:end-1), E2)
plot(t3(1:end-1), E3)
Which gives the following,
Upvotes: 0
Reputation: 35525
2 things:
1.- The last line of your code throws an error. Its wrong.
2.- The plots are there, its just you dont' see them. Try adding axis([0 1 0 1])
to zoom out! Try to figure out which are your limits (not 0-1, 0-1 for sure ;))
Upvotes: 2