differential equation huen plotting problem
Mostrar comentarios más antiguos
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!!!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Numerical Integration and Differential Equations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

