MATLAB Answers

Simple fixed-point iteration method

조회 수: 822(최근 30일)
John  Smith
John Smith 2019년 9월 22일
답변: Ishita Sharma 2020년 8월 18일
My task is to implement (simple) fixed-point interation.
So far, I've got the following and I keep receiving error Undefined function 'fixedpoint' for input arguments of type 'function_handle'.
(I'm new in Matlab, so there may be both syntactical or semantical errors...)
function [ x ] = fixedpoint(g,I,y,tol,m)
% input: g, I, y, tol, max
% g - function
% I - interval
% y - starting point
% tol - tolerance (error)
% m - maximal number of iterations
% x - approximate solution
a=I(1);b=I(2);
if(y<a | y>b)
error('The starting iteration does not lie in I.')
end
x=y;
gx=g(y);
while(abs(x-gx)>tol & m>0)
if(gx<a | gx>b)
error('The point g(x) does not lie in I.')
end
y=x;
x=g(y);
m=m-1;
end

채택된 답변

Dimitris Kalogiros
Dimitris Kalogiros 2019년 9월 22일
Dear John
Put your function into the same folder with the program (m-file) that calls it.
  댓글 수: 4
Dimitris Kalogiros
Dimitris Kalogiros 2019년 9월 24일
Hm hm, I don't know if it is necessary , but I always follow this rule.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Ishita Sharma
Ishita Sharma 2020년 8월 18일
f(x)=x^2 - x -1 =0

Community Treasure Hunt

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

Start Hunting!

Translated by