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!

