Fixed Point Iteration in Numerical Methods for any equation

조회 수: 3 (최근 30일)
Micah Benize Gregorio
Micah Benize Gregorio 2021년 2월 27일
답변: Vimal Rathod 2021년 3월 3일
This code is for exp(-x)-x only, but I want to edit the program so it can compute any other equation using input('Enter the equation: ')
format('long','g')
i=1;
x(i)=0; %initial value
Ea=0.001;
error(i)=9999;
while error(i)>=Ea
x(i+1)=exp((-x(i)));
error(i+1)=abs(((x(i+1)-x(i))/(x(i+1))));
i=i+1;
end
disp(' root Ea(%)');
disp([x',error'])

답변 (1개)

Vimal Rathod
Vimal Rathod 2021년 3월 3일
Hi,
If you want to get the equation through string input you could use "str2func" to convert the string to function. The function format to use is of "Anonymous Function".

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by