What is wrong with my code?
Ältere Kommentare anzeigen
% Itfinds the velocity using RK 4 method
clc; % Clears the screen
clear all;
F = @(t,v) 9.81 - ((0.28/85) * (v^2));
t0 = input('Insert the value of the initial time: ');
v0 = input('Insert the value of the initial velocity: ');
tfinal = 20;
h = input('Insert the value of the step size: ');
v = RK_4(F,t0,h,tfinal,v0);
Antworten (1)
Ameer Hamza
am 25 Okt. 2020
0 Stimmen
You need to write the RK_4 function. Right now, RK_4 is the name of your current script. You can find one implementation of the Runge Kutta-4 algorithm here: https://www.mathworks.com/matlabcentral/fileexchange/29851-runge-kutta-4th-order-ode
4 Kommentare
Ibrahim Butt
am 25 Okt. 2020
Ameer Hamza
am 25 Okt. 2020
In function handle
F_xy = @(v,t) 9.81 - ((0.28/85) * (v^2));
You have specified v as first input and t as second. But inside the for-loop, you are doing the opposite. Apart from that, your equations seems correct.
Ibrahim Butt
am 3 Nov. 2020
Thank you very much for helping me in correcting my mistakes and clearing my doubts.
Ameer Hamza
am 4 Nov. 2020
I am glad to be of help!!!
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!