필터 지우기
필터 지우기

Plotting help

조회 수: 3 (최근 30일)
John
John 2011년 3월 27일
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')

채택된 답변

Paulo Silva
Paulo Silva 2011년 3월 27일
replace figure(2) by
hold on

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by