Prev: www.jerseysexport.com NFL Shop Cheap Football Wholesale Jerseys
Next: Interpolation to arbitrary plane through 3D image / decimal truncation issue
From: deepak on 20 Jun 2010 05:41 Hi, I am trying to call the value of a variable in the function while using fsolve.This variable changes it's value every time so it can't be defined in the code of function itself. for example if function is defined as function F=myfunt(x) F=[x(1)^2 +x(2)+x(3)-c(1);x(2)^2 +x(1)+x(3)-c(2); x(1)^2 +x(3)+x(2)-c(3)]; in this case i want function to take value of vector c from main program. How can i do this. Thnx and regards, Deepak
From: Gang-Gyoo on 20 Jun 2010 06:30
Hi, The following is a piece of code which you may want. Gang-Gyoo ---------------------------------------------------------------------------- function test x0= [1;2;3] %define initial vector x0 for i= 1:10 % put the statement 'if' if you want c= [1;2;3]; %define vector c x= fsolve(@(x) myfunt(x,c),x0) end function F= myfunt(x,c) F= [x(1)^2 +x(2)+x(3)-c(1);x(2)^2 +x(1)+x(3)-c(2); x(1)^2 +x(3)+x(2)-c(3)]; |