How can i adapt Euloer backward method
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1107280/image.png)
Solve this by eulor backward method
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1107285/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1107290/image.png)
then I write BW code in matlab simply
% dy/dt=y-t^2+1 ; 0<=t<=2 ; y(0)=0.5;
clc,clear;close all;
f = @(t,y) (y-t^2+1);
a = 0; %input('initial ponit, a: ');
b = 100; %input('end point, b: ');
n = 10; %input('intervals, n: ');
alpha = 166*10^(4); %input('initial condition, alpha: ');
h = (b-a)/n;
t=[a zeros(1,n)];
y=[alpha zeros(1,n)];
for i = 1:n+1
t(i+1)=t(i)+h;
yprime=y(i)+h*f(t(i),y(i)); %slope
y(i+1)=y(i)+h*f(t(i+1),yprime);
delta=y(i+1)-yprime;
fprintf('%.4f %.4f\n', t(i), y(i));
figure(1)
plot(t(i),y(i),'r*');
grid on;
plot(t(i),delta,'g*',t(i),yprime,'b*');
xlabel('t values'); ylabel('y values');
hold on;
legend('delta','yprime','BW')
end
then how can i adapt it???
1 comentario
Torsten
el 25 de Ag. de 2022
Editada: Torsten
el 25 de Ag. de 2022
The code you use isn't Euler backward.
And the formula to compute N''_exist,i is already given (you wrote it in your question). So there is no need to use an Euler backwards integrator from the File Exchange (or whereever you got the code from).
Respuestas (0)
Ver también
Categorías
Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!