Please, how can I solve runKut4 in line 6?
1 view (last 30 days)
Show older comments
Stephen Akosah
on 8 Jan 2021
Commented: Stephen Akosah
on 8 Jan 2021
t = 0.0;
tStop = 6.0;
y = [1.5 0];
h = 0.1;
[T,Y] = runKut4(@dEqs,t,y,tStop,h);
plot(T,Y(:,1),'ko-')
xlabel('time (s)'); ylabel('h/r')
grid on
function F = dEqs(x,y)
p = sqrt(2*y(1) - y(1)^2);
q =1 - y(1);
F = zeros(1,2);
F(1) = y(2);
F(2) = 2/pi*(atan(q/p) + q*p);
end % function dEqs
end
0 Comments
Accepted Answer
Alan Stevens
on 8 Jan 2021
Try
t = 0.0;
tStop = 6.0;
y = [1.5 0];
h = 0.1;
[T,Y] = ode45(@dEqs,[0 tStop],y);
plot(T,Y(:,1),'ko-')
xlabel('time (s)'); ylabel('h/r')
grid on
function F = dEqs(x,y)
p = sqrt(2*y(1) - y(1)^2);
q =1 - y(1);
F = zeros(2,1);
F(1) = y(2);
F(2) = 2/pi*(atan(q/p) + q*p);
end % function dEqs
More Answers (0)
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!