i have an error at line 13 xi1 and below it. how to correct it for runge kutta method

2 次查看(过去 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
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 个)

Neelanshu
Neelanshu 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.

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by