필터 지우기
필터 지우기

I need a detailed explination of this code

조회 수: 2 (최근 30일)
Sonja Cortes
Sonja Cortes 2020년 3월 24일
답변: Ameer Hamza 2020년 3월 24일
So I have this script but i have no clue what it does, and I got the text that says that it is Euler's method to find an approximate solution to the startvalue problem
y' = sin(sqrt(x+y)) with the start value y(0) = 0.4
on the intervall [0,20]. And the following code implements Euler's methode and plots the graph for the approximat solution of y.
But I was wondering what this script does.
So can someone please explain to me line by line what it does?
ymark = @(x,y) sin(sqrt(x+y));
t = 0:0.01:20;
y = zeros(1,length(t));
y(1) = 0.04;
dt = diff(t);
for s= 1:length(t)-1
y(s+1) = y(s)+dt(s)*ymark(t(s),y(s));
end
plot(t,y)
  댓글 수: 1
John D'Errico
John D'Errico 2020년 3월 24일
편집: John D'Errico 2020년 3월 24일
Do you have any clue what a differential equation is, what it means, etc.? Because Euler's method is the most basic numerical method you will ever see for solving an ordinary differetial equation.
This is what students are taught when they are introduced to the idea of solving an ODE numerically. In fact, the comments that you show, indicate exactly the differential equation that is approximately solved, including the initial value at t==0.
So are you asking someone to tutor you about differential equations from scratch? Taught well, this usually involves a semester or two.

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

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 3월 24일

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by