Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fixed point Iteration (multivariable)

Subject: Fixed point Iteration (multivariable)

From: Sean Douglas

Date: 1 Jul, 2009 21:37:01

Message: 1 of 3

I just performed fixed point iteration, here is my Mfile program:
%Program 1.2 Fixed-Point Iteration
%Computes approximate solution of g(x)=x
%Input: inline function g, starting guess x0,
% number of steps k
%Output: Approximate solution xc
function xc=fpi(g,x0,k)
x(1)=x0;
for i=1:k
  x(i+1)=g(x(i));
end
x' %transpose output to a column
xc=x(k+1);

then after defining x here is the function I used:
x=fpi(inline('cos(x)'),2/3,20)

this worked. Now i am trying to perform fixed point iteration on a multiavariable function and i dont know how to set the function up. would I have to change my Mfile program???
here is the multivariable function:
 x1=g1(x1,x2)=(x1^2+x2^2+8)/10, x2=g2(x1,x2)=(x1*x2^2+x1+8)/10

here is where i am with it:
>> clear
>> x=-10:.001:10;
>> y=-10:.001:10;
>> x=fpi(inline('((x.^2+y.^2+8)/10)'),.5,2)
??? Error using ==> inline.subsref at 14
Not enough inputs to inline function.

Error in ==> fpi at 9
  x(i+1)=g(x(i));

please be specific with my errors and what I need to do because i am just a beginner. Thank you

Subject: Fixed point Iteration (multivariable)

From: Nathan

Date: 1 Jul, 2009 21:57:41

Message: 2 of 3

On Jul 1, 2:37 pm, "Sean Douglas" <seanjdoug...@hotmail.com> wrote:
> I just performed fixed point iteration, here is my Mfile program:
> %Program 1.2 Fixed-Point Iteration
> %Computes approximate solution of g(x)=x
> %Input: inline function g, starting guess x0,
> %       number of steps k
> %Output: Approximate solution xc
> function xc=fpi(g,x0,k)
> x(1)=x0;
> for i=1:k
>   x(i+1)=g(x(i));
> end
> x'                 %transpose output to a column
> xc=x(k+1);
>
> then after defining x here is the function I used:
> x=fpi(inline('cos(x)'),2/3,20)
>
> this worked.  Now i am trying to perform fixed point iteration on a multiavariable function and i dont know how to set the function up.  would I have to change my Mfile program???  
> here is the multivariable function:
>  x1=g1(x1,x2)=(x1^2+x2^2+8)/10,   x2=g2(x1,x2)=(x1*x2^2+x1+8)/10
>
> here is where i am with it:>> clear
> >> x=-10:.001:10;
> >> y=-10:.001:10;
> >>  x=fpi(inline('((x.^2+y.^2+8)/10)'),.5,2)
>
> ??? Error using ==> inline.subsref at 14
> Not enough inputs to inline function.
>
> Error in ==> fpi at 9
>   x(i+1)=g(x(i));
>
> please be specific with my errors and what I need to do because i am just a beginner. Thank you

Well, it looks like your inline function takes in two inputs and
you're only sending it one.
> x(i+1)=g(x(i));
You are only sending g (your inline function) x values when the
equation calls for x and y values.
Unless I'm reading it wrong, that's what I see.

Hope that helps.
-Nathan

Subject: Fixed point Iteration (multivariable)

From: Sean Douglas

Date: 1 Jul, 2009 22:25:03

Message: 3 of 3

Nathan thanks, I will be busy for a while playing with this... maybe i will back later.

thanks

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us