From help-octave-request at bevo dot che dot wisc dot edu Fri May 30 17:50:58 2003 Subject: Re: matrix of variables? From: Heber Farnsworth To: jdonner Cc: help-octave at bevo dot che dot wisc dot edu Date: Fri, 30 May 2003 17:51:00 -0500 Define x as a vector and then reshape it into a matrix within the function. x = reshape(x,5,5); Heber Farnsworth On Friday, May 30, 2003, at 05:12 PM, jdonner wrote: > Hi, > > I'm trying to solve a non-linear equation with 25 vars, > and it works when I number them from x(1) .. x(25) but, > they naturally are a 2D array of variables, is there some way I can I > use matrix notation for convenience? > When I try to say this: > function y = f (x) > g = 0.9; > # center parts > y(2,2) = -1 * x(2,2) + (1/4)*g*(x(1,2) + x(2,1) + x(2,3) + x(3,2)); > y(2,3) = -1 * x(2,3) + (1/4)*g*(x(1,3) + x(2,2) + x(2,4) + x(3,3)); > ... more > > I get: > error: invalid column index = 2 > error: evaluating binary operator `*' near line 4, column 13 > error: evaluating binary operator `+' near line 4, column 22 > error: evaluating assignment expression near line 4, column 8 > error: called from `f' > error: fsolve: evaluation of user-supplied function failed > > > Is there a way to do this? > Thanks, > > Jeff > > > > ------------------------------------------------------------- > Octave is freely available under the terms of the GNU GPL. > > Octave's home on the web: http://www.octave.org > How to fund new projects: http://www.octave.org/funding.html > Subscription information: http://www.octave.org/archive.html > ------------------------------------------------------------- > ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------