differential equation huen plotting problem
이전 댓글 표시
x_a=linspace(0,2,n)
h=x_a(n)-x_a(n-1)
y_a=((x_a.^2+1/2.*x_a+1)).^2
for i=1:n-1 ;
x_h=linspace(0,2,n)
h_h=x_h(n)-x_h(n-1)
A(i)=x_h(i)+h_h
B(i)=y_h(i)+h_h*(1+4.*x_h(i)).*sqrt(y_h(i))
L(i)=(1+4.*x_h(i)).*sqrt(y_h(i))
R(i)=(1+4.*A(i)).*sqrt(B(i))
y_h(1)=1;
y_h(i+1)=y_h(i)+1/2.*(h_h.*L(i).*R(i))
i=i+1;
end
plot(x_a,y_a,'--kd')
hold on
plot(x_h,y_h,'--rx')
Above code is to comapre the value of diffrenetial equation by analytic method and huen method by plotting it on graph.
But,Dont know why its not plotting the graph correctly.
If I am plotting the analytic solution graph individually its plotting the correct graph.But when I am plotting the two graphs together,none of the two graphs are correct.
Please help!!!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

