Effacer les filtres
Effacer les filtres

Plotting help

3 vues (au cours des 30 derniers jours)
John
John le 27 Mar 2011
I want to plot an anonymous function on the same plot of a numerical euler's method solution to a problem. My code is below (I have both plots working but I want them to be on the same plot not 2 separate plots)
%%Analytical
simplify(dsolve('Dy=-x/y','y(0)=5','x'))
%%Numerical
f=@(x) (-x^2+25)^(1/2);
dydx=@(x,y) -(x/y);
[x1,y1]=eulode(dydx, [0 1],5,.5);
[x2,y2]=eulode(dydx,[0 1],5,.1);
[x3,y3]=eulode(dydx,[0 1],5,.01);
disp([x1,y1])
disp([x2,y2])
disp([x3,y3])
%%Plot
plot(x1,y1,'k',x2,y2,'b',x3,y3,'g','linewidth',2)
figure(2)
fplot(f,[0 5],'linewidth',2,'k')

Réponse acceptée

Paulo Silva
Paulo Silva le 27 Mar 2011
replace figure(2) by
hold on

Plus de réponses (0)

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by