calculate and plot the following differential equation using ODE45solver.

조회 수: 1 (최근 30일)
sz
sz 2020년 6월 16일
편집: Stephan 2020년 6월 16일
I would loke to calculate and plot the following differential equation using ODEsolver.
But I get error.
Please take care of me.
I want to know who understands
y'(t)=-y(t)+sin(t)
y0=0.5; %intial value
h=0.8; %
t=0:0.8:4; %tspan
script
[t,y] =ode45(@-y(t)+sin(t), t,y0);error
plot(t,y,'-o');
xlabel('time');
ylabel('y');

채택된 답변

Stephan
Stephan 2020년 6월 16일
편집: Stephan 2020년 6월 16일
y0=0.5; %intial value
h=0.8; %
t=[0 4]; %tspan
[t,y] =ode45(@(t,y)-y+sin(t), t,y0);
plot(t,y,'-o');
xlabel('time');
ylabel('y');

추가 답변 (0개)

카테고리

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