# [Scilab-users] fsolve including linear interpolation

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

## [Scilab-users] fsolve including linear interpolation

 Hi All I'm wondering what is the way to solve the following study (but at the same time I'm not sure that the problem has been correctly posed) ... I'm a bit "disrupted" by theta scalar that depends itself on x value.   The problem seems to be non linear and I tried (but I failed) in using fsolve.   Any suggestion where I've to see to?   Thanks for your time and help   Paul       ################################################# ```function y=calculus(x) theta = [ 1 100 200 300 1000 1200 1500 2000]'; theta_interp = interp1(theta(:,1),theta(:,2),x,'linear'); y = -theta_interp * 0.268 + 120 -x; //pause // if theta = 1 : y = 0 -> x = 120 - 0.268 = 119.73 // if theta = 100 : y = 0 -> x = 120 - 26.8 = 93.2 // if theta = 200 : x = 66.4 // if theta = 300 : x = 120 - 0.268 = 39.6 // can we say that y belongs to [39.6 , 119.73] ? endfunction [x,v,info] = fsolve(0,calculus) ``` _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|
Report Content as Inappropriate

## Re: fsolve including linear interpolation

 Paul: It appears that you're solving for y given theta and x, but y is a linear function of theta and x. I don't have a good knowledge of what you are trying to solve, but when I solve nonlinear problems I normally either have a form of first-order derivative (scalar or a Jacobian), or some form of branching/discontinuity from which I need to choose the "best" solution. For linear interpolation, I find that it's easier to simply write a function myself than try to figure out how to make a given built-in function works. I'm going fishing here: in your function, theta is 8x1 but your arguments for interpl are theta(:,1),theta(:,2), which presumes that theta is 8x2, so that could be a place to start looking at why fsolve is giving your grief. Regards, Roger. ______________________________________________ Dr. Roger Cormier, P.Eng. Home Tel. & Fax: 613-823-7299 Am mar. 18 avr. 2017 um 09:03 schrieb [hidden email]: > Hi All > > I'm wondering what is the way to solve the following study (but at the same time I'm not sure that the problem has been correctly posed) ... I'm a bit "disrupted" by theta scalar that depends itself on x value. >   > The problem seems to be non linear and I tried (but I failed) in using fsolve. >   > Any suggestion where I've to see to? >   > Thanks for your time and help >   > Paul >   >   >   > ################################################# > function y=calculus(x) >     >     > theta = [ 1 100 200 300 > >     > 1000 1200 1500 2000]'; >   > >     > theta_interp = interp1(theta(:,1),theta(:,2),x,'linear'); > >     > y = -theta_interp * 0.268 + 120 -x; //pause > >     >     > // if theta = 1 : y = 0 -> x = 120 - 0.268 = 119.73 > >     > // if theta = 100 : y = 0 -> x = 120 - 26.8 = 93.2 > >     > // if theta = 200 : x = 66.4 > >     > // if theta = 300 : x = 120 - 0.268 = 39.6 > >     >     > // can we say that y belongs to [39.6 , 119.73] ? > > > > endfunction > > > > [x,v,info] = fsolve(0,calculus) > > > > _______________________________________________ > users mailing list > [hidden email] > http://lists.scilab.org/mailman/listinfo/users_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users