Heun's Method program code

%%%% I can't figure out why my function 'HeunIter' doesnot work; even cannot try it! >>>>>>>>>>>>>> function HeunIter(x, y, h, ynew)
es=0.01;
maxit=20;
Call Derivs(x, y, dy1dx);
ye=y+dy1dx*h;
iter=0;
while (ea>es or iter<=maxit)
yeold=ye;
call Derivs(x+h,ye,dy2dx);
slope=(dy1dx+dy2dx)/2;
ye=y+slope*y;
iter=iter+1;
ea=abs((ye-yeold)/ye)*100;
end
ynew=ye
x=x+h
end
%%%% Below is when i try to run function.
>> HeunIter(0,4800,1,2) 'HeunIter'은(는) 정의되지 않은 함수 또는 변수입니다. %%%% It means 'HeunIter' is undefined function or variable. (In korean)

回答(1 个)

Hojin Jung
Hojin Jung 2018-6-8

0 个投票

I also have another function above :
function Derivs(x, y, deriv) deriv=4800-0.6*y/(1-0.025*x); end

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by