i have an error at line 13 xi1 and below it. how to correct it for runge kutta method
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function [y1] = RK21(x0, y0, h, f)
%RK21.m apply one step of the explicit RK2 method
% with Butcher Tableau:
% 0
% 2/3 2/3
% 1/4 3/4
%
% xi1 = yk
% xi2 = yk + a21*h*f(xk + c1*h, xi1)
% yk+1 = yk + h( b1*f(xk+c1*h, xi1 ) + b2*f(xk+c2*h, xi2)
xi1 = 0;
xi2 = y0 + 2/3*h*f(x1/4+1/4*h, xi3/4);
y1 = y0 + h*( 1/4*f(x1/4+1/4*h, xi3/4) + 3/4*f(x1/4+2/3*h, xi2 ));
1 Kommentar
Jan
am 25 Nov. 2021
If you mention an error in the forum, add a copy of the complete message also. It is much easier to solve a problem than to guess, what the problem is.
Antworten (1)
nick
am 10 Mai 2024
Hi Alec,
As Jan mentioned, kindly describe the error you encountered. I assume that the error is Unrecognized function or variable because the equations for computating xi2 and y1 utilize xi3, which hasn't been defined in the function workspace.You'll need to define xi3 before you can compute xi2 and y1 within the function.
Hope this helps.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!