i have an error at line 13 xi1 and below it. how to correct it for runge kutta method
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Jan
2021년 11월 25일
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.
답변 (1개)
nick
2024년 5월 10일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!