How do I plot this?
이전 댓글 표시
Hi I have used bvp4c to find a numerical solution to a problem. I want to be able to plot this numerical solution on a graph as well as the analytical solution, but have no idea how to do this. Any help would be grealy appreciated.
Code:
init: if true % function v=init(x) v=[2*x+pi^2/2 1-4*x/pi 4*x/pi 2*x/pi]; end
odefun: if true % function dyds_tilde=odefun(x,s_tilde,a) p=1; dyds_tilde=[(p/(a-1))*a a*cos(s_tilde(2 a*sin(s_tilde(2)) a ]; end
bcfun:
if true
% function res=bc(s_tilde0,s_tilde1,a)
res=[s_tilde0(4)
s_tilde0(2)
s_tilde0(3)
s_tilde1(1)-pi
s_tilde1(2)];
end
bvp: if true % a=0.25; solinit=bvpinit(linspace(0,1),@init,a); sol=bvp4c(@odefun, @bcfun, solinit) fprintf('a = %g. \n', sol.parameters); end
The analytical solution is:
x=(a-1/p)*cos(pi*s_tilde)+(a-1)/p; y=(a-1/p)*sin(pi*s_tilde); theta=p*a/(a-1)*(s_tilde-1)+pi; s=a*s_tilde;
답변 (2개)
Azzi Abdelmalek
2012년 11월 17일
0 개 추천
Star Strider
2012년 11월 17일
0 개 추천
I suggest using the deval function. The documentation explains its use, and illustrates a plot as well.
카테고리
도움말 센터 및 File Exchange에서 Boundary Value Problems에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!