help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

passing a structure to fsolve


From: altomare
Subject: passing a structure to fsolve
Date: Tue, 22 Mar 2011 13:03:59 -0700 (PDT)

Hi all,

I would like to pass a structure to fsolve but so far I did not have any
luck
Minimal example:
%%
clear all

function r = gtest(str)
r=str.a-str.b;
endfunction
test.a=2;
test.b=3;


If I type: gtest(test) I get 
ans = -1
However 
[x, fval, info] = fsolve (@(var) gtest(var),test)
returns:
error: Invalid call to fsolve.  Correct usage is: ...
It looks to me that I cannot pass a structure to fsolve. If that is the
case, how can I circumvent the problem? Passing two variables? Can someone
provide a minimal example?
I was looking at a structure because I have 
struc(i,j).a struc(i,j).b struc(i,j).c struc(i,j).d which, for each i and j,
have dimension 1.
However I also need to pass struc(i,j).e which is a vector.
Any help is appreciated.
Thanks
fabio 



--
View this message in context: 
http://octave.1599824.n4.nabble.com/passing-a-structure-to-fsolve-tp3397586p3397586.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]