[prev in list] [next in list] [prev in thread] [next in thread] 

List:       scilab-users
Subject:    Re: [Scilab-users] fsolve including linear interpolation
From:       paul.carrico () free ! fr
Date:       2017-04-18 17:12:33
Message-ID: 6fa22ebf4f491d68fef628fd7164fd4e () free ! fr
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


the example I built is not relevant and it does not reflect the problem
behind... sorry for the inconvenient 

Paul 

Le 2017-04-18 17:20, roger.cormier@ncf.ca a écrit : 

> 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 paul.carrico@free.fr:
> 
> > 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
> > users@lists.scilab.org
> > http://lists.scilab.org/mailman/listinfo/users
> 
> _______________________________________________
> users mailing list
> users@lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" \
/></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'> <div \
class="pre" style="margin: 0; padding: 0; font-family: monospace">the example I built \
is not relevant and it does not reflect the problem behind... sorry for the \
inconvenient</div> <div class="pre" style="margin: 0; padding: 0; font-family: \
monospace">&nbsp;</div> <div class="pre" style="margin: 0; padding: 0; font-family: \
monospace">Paul</div> <div class="pre" style="margin: 0; padding: 0; font-family: \
monospace">&nbsp;</div> <div class="pre" style="margin: 0; padding: 0; font-family: \
monospace">&nbsp;</div> <div class="pre" style="margin: 0; padding: 0; font-family: \
monospace">Le 2017-04-18 17:20, <a \
href="mailto:roger.cormier@ncf.ca">roger.cormier@ncf.ca</a> a &eacute;crit&nbsp;: \
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; \
margin: 0">Paul:<br /> <br /> It appears that you're solving for y given theta and x, \
but y is a<br /> linear function of theta and x.<br /> <br /> I don't have a good \
knowledge of what you are trying to solve, but<br /> when I solve nonlinear problems \
I normally either have a form of<br /> first-order derivative (scalar or a Jacobian), \
or some form of<br /> branching/discontinuity from which I need to choose the \
"best"<br /> solution. For linear interpolation, I find that it's easier to simply<br \
/> write a function myself than try to figure out how to make a given<br /> built-in \
function works.<br /> <br /> I'm going fishing here: in your function, theta is 8x1 \
but your<br /> arguments for interpl are theta(:,1),theta(:,2), which presumes \
that<br /> theta is 8x2, so that could be a place to start looking at why fsolve<br \
/> is giving your grief.<br /> <br /> Regards,<br /> <br /> <br /> Roger.<br /> <br \
/> ______________________________________________<br /> Dr. Roger Cormier, P.Eng.<br \
/> Home Tel. &amp; Fax: 613-823-7299<br /> <br /> <br /> Am mar. 18 avr. 2017 um \
09:03 schrieb <a href="mailto:paul.carrico@free.fr:">paul.carrico@free.fr:</a><br /> \
<br /> <blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px \
solid; margin: 0">Hi All<br /> <br /> 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.<br /> <br /> The problem seems to be non linear and I tried (but I failed) in \
using fsolve.<br /> <br /> Any suggestion where I've to see to?<br /> <br /> Thanks \
for your time and help<br /> <br /> Paul<br /> <br /> <br /> <br /> \
#################################################<br /> function y=calculus(x)<br /> \
<br /> <br /> theta = [ 1 100 200 300<br /> <br /> <br /> 1000 1200 1500 2000]';<br \
/> <br /> <br /> <br /> theta_interp = interp1(theta(:,1),theta(:,2),x,'linear');<br \
/> <br /> <br /> y = -theta_interp * 0.268 + 120 -x; //pause<br /> <br /> <br /> <br \
/> // if theta = 1 : y = 0 -&gt; x = 120 - 0.268 = 119.73<br /> <br /> <br /> // if \
theta = 100 : y = 0 -&gt; x = 120 - 26.8 = 93.2<br /> <br /> <br /> // if theta = 200 \
: x = 66.4<br /> <br /> <br /> // if theta = 300 : x = 120 - 0.268 = 39.6<br /> <br \
/> <br /> <br /> // can we say that y belongs to [39.6 , 119.73] ?<br /> <br /> <br \
/> <br /> endfunction<br /> <br /> <br /> <br /> [x,v,info] = fsolve(0,calculus)<br \
/> <br /> <br /> <br /> _______________________________________________<br /> users \
mailing list<br /> <a \
href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br /> <a \
href="http://lists.scilab.org/mailman/listinfo/users" target="_blank" \
rel="noreferrer">http://lists.scilab.org/mailman/listinfo/users</a></blockquote> <br \
/> _______________________________________________<br /> users mailing list<br /> <a \
href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br /> <a \
href="http://lists.scilab.org/mailman/listinfo/users" target="_blank" \
rel="noreferrer">http://lists.scilab.org/mailman/listinfo/users</a></blockquote> \
</div> </body></html>



_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic