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