Path: news.mathworks.com!not-for-mail
From: "Steve Conahan" <sconahan@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Fixed point Iteration (multivariable) 2
Date: Thu, 2 Jul 2009 15:58:53 -0400
Organization: The MathWorks, Inc.
Lines: 84
Message-ID: <h2j3hu$mq4$1@fred.mathworks.com>
References: <h2ipv9$h8m$1@fred.mathworks.com>
Reply-To: "Steve Conahan" <sconahan@mathworks.com>
NNTP-Posting-Host: conahans.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1246564734 23364 144.212.109.242 (2 Jul 2009 19:58:54 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 2 Jul 2009 19:58:54 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:552524


Hi Sean,

> ??? Error: File: fpixy.m Line: 7 Column: 9

As indicated, Line: 7 needs some re-writing:

  x(1)=(x0,y0);

I am not exactly sure what you are trying to do, but I suspect that the 
right hand side of the above equation is not written correctly...perhaps you 
need square braces [ instead of parentheses ( on the right hand side...

hth,
Steve


"Sean Douglas" <seanjdouglas@hotmail.com> wrote in message 
news:h2ipv9$h8m$1@fred.mathworks.com...
> Hello I am trying to perform fixed point iteration on this problem:
> x1=g1(x1,x2)=(x1^2+x2^2+8)/10,   x2=g2(x1,x2)=(x1*x2^2+x1+8)/10
>
> first I made it one variable since I am x1 and x2 will be equal to each 
> other anyways.                  Here is my mfile:
> %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 I defined x and did the inline function:
>>> clear
>>> x=-10:.001:10;
>>> x=fpi(inline('((x.^2+x.^2+8)/10)'),.5,2)
>
> ans =
>
>    0.5000
>    0.8500
>    0.9445
>
>
> x =
>
> 0.9445 this worked nicely
>
>
> Now I am trying to do this how the question was set up (with 
> mulivariables). I changed my mfile and tried to do it. Here is what I have 
> been up to:
> First here is my new modified mfile:
> %Attempting to set up multivariable 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,y0,k)
> x(1)=(x0,y0);
> for i=1:k
>  x(i+1)=g(x(i),y(i));
> end
> x'                 %transpose output to a column
> xc=x(k+1);
>
> &#8230; and here is me calling the function and the MATLAB response
>>> clear
> x=-10:.001:10;
> y=-10:.001:10;
>>> x=fpixy(inline('((x.^2+y.^2+8)/10)'),.5,.5,2)
> ??? Error: File: fpixy.m Line: 7 Column: 9
> Expression or statement is incorrect--possibly unbalanced (, {, or [.
>
> I am pretty sure that it is not unbalaced, but something must be wrong 
> with line 7 of my mfile, which is:  x(1)=(x0,y0);
>
> Can I even do a multivariable FPI?
> I hope I described my situation clearly. Thanks for any help.