필터 지우기
필터 지우기

How can i adapt Euloer backward method

조회 수: 1 (최근 30일)
주선 문
주선 문 2022년 8월 25일
편집: Torsten 2022년 8월 25일
Solve this by eulor backward method
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
0.0000 1660000.0000
Warning: Ignoring extra legend entries.
10.0000 184259110.0000 20.0000 20452747320.0000 30.0000 2270254903630.0000 40.0000 251998294197040.0000 50.0000 27971810655686552.0000 60.0000 3104870982780921344.0000 70.0000 344640679088681844736.0000 80.0000 38255115378843688370176.0000 90.0000 4246317807051649023213568.0000 100.0000 471341276582733031376158720.0000
then how can i adapt it???
  댓글 수: 1
Torsten
Torsten 2022년 8월 25일
편집: Torsten 2022년 8월 25일
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).

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by