using ode 45 to estimate the derivative
1 次查看(过去 30 天)
显示 更早的评论
Question: Use ode45 to estimate y'(3), where y is the solution to the initial value problem y" + (1/t)*y = 0 ; y(0) = 0, y'(0) = 2. Note I'm asking for an estimate of the derivative, not the function itself.
Attempted code:
ode = @(t, y) [y(2) ; (1/t)*y(1)];
[t, y] = ode45(ode, [-1, 3], [0, 2]);
y(end, 1);
I do not think this actual estimating the derivative y'(3)?
1 个评论
Torsten
2016-8-8
1. y''=-1/t*y, thus
ode = @(t, y) [y(2) ; -(1/t)*y(1)];
2. Why do you start integration at t=-1 if your initial conditions are given at t=0 ?
3. Your y(1) is the solution of the ODE y''+1/t*y=0, your y(2) is its derivative ... So to estimate the derivative at t=3, you will have to evaluate y(2) there.
Best wishes
Torsten.
采纳的回答
Azzi Abdelmalek
2016-8-8
ode=@(t, x) [x(2) ; -(1/t)*x(1)];
[t, x] = ode45(ode, [-1, 3], [0, 2]);
y=x(:,1)
dy=x(:,2)
out=dy(3)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!