<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264861</link>
    <title>MATLAB Central Newsreader - how to solve a set of nonlinear equation systems with changing coefficients</title>
    <description>Feed for thread: how to solve a set of nonlinear equation systems with changing coefficients</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 03 Nov 2009 18:23:02 -0500</pubDate>
      <title>how to solve a set of nonlinear equation systems with changing coefficients</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264861#691789</link>
      <author>Gyusok </author>
      <description>Hello,&lt;br&gt;
&lt;br&gt;
I have to solve the following problem; I hope that someone can help me.&lt;br&gt;
I would like to solve the function and obtain a vector x = [x(1); x(2)]&lt;br&gt;
for varying values of theta and the vector p =[ p(1); p(2)]&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
function findphi = findphi(x)&lt;br&gt;
findphi = [cos(theta)*(sin(x(1)) - x(2)*x(1)*cos(x(1))) + ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sin(theta) * (cos(x(1)) + x(2) * x(1) * cos(x(1))) - p(1) ;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-sin(theta) * (sin(x(1)) - x(2) * x(1) * cos(x(1))) + ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cos(theta) * (cos(x(1)) + x(2) * x(1) * cos(x(1))) - p(2)];&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&lt;br&gt;
I could use the 'fsolve' command for one specific case, but I have to do this 77 times for changing values of p and theta.&lt;br&gt;
&lt;br&gt;
e.g. if I insert&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
x0 = [0.7; 1]&lt;br&gt;
x = fsolve('findphi', x0)&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
The values of the coefficients are not known to the function 'findphi' although present in workspace.&lt;br&gt;
Does anybody know how I can pass these coefficients to my function?&lt;br&gt;
&lt;br&gt;
Is there any suitable way for stack processing this?&lt;br&gt;
&lt;br&gt;
Thank you for your help-.&lt;br&gt;
&lt;br&gt;
Gyusok</description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 20:50:19 -0500</pubDate>
      <title>Re: how to solve a set of nonlinear equation systems with changing coefficients</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264861#691834</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;Gyusok &quot; &amp;lt;gyusok@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:hcpse6$7ac$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have to solve the following problem; I hope that someone can help me.&lt;br&gt;
&amp;gt; I would like to solve the function and obtain a vector x = [x(1); x(2)]&lt;br&gt;
&amp;gt; for varying values of theta and the vector p =[ p(1); p(2)]&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; function findphi = findphi(x)&lt;br&gt;
&amp;gt; findphi = [cos(theta)*(sin(x(1)) - x(2)*x(1)*cos(x(1))) + ...&lt;br&gt;
&amp;gt;          sin(theta) * (cos(x(1)) + x(2) * x(1) * cos(x(1))) - p(1) ;&lt;br&gt;
&amp;gt;         -sin(theta) * (sin(x(1)) - x(2) * x(1) * cos(x(1))) + ...&lt;br&gt;
&amp;gt;          cos(theta) * (cos(x(1)) + x(2) * x(1) * cos(x(1))) - p(2)];&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I could use the 'fsolve' command for one specific case, but I have to do &lt;br&gt;
&amp;gt; this 77 times for changing values of p and theta.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; e.g. if I insert&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; x0 = [0.7; 1]&lt;br&gt;
&amp;gt; x = fsolve('findphi', x0)&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; The values of the coefficients are not known to the function 'findphi' &lt;br&gt;
&amp;gt; although present in workspace.&lt;br&gt;
&amp;gt; Does anybody know how I can pass these coefficients to my function?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Is there any suitable way for stack processing this?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thank you for your help-.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Gyusok&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
one way is to use global&lt;br&gt;
&lt;br&gt;
FUNCTION&lt;br&gt;
============&lt;br&gt;
&lt;br&gt;
function findphi = findphi(x)&lt;br&gt;
&lt;br&gt;
global p theta&lt;br&gt;
&lt;br&gt;
findphi = [cos(theta)*(sin(x(1)) - x(2)*x(1)*cos(x(1))) + ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sin(theta) * (cos(x(1)) + x(2) * x(1) * cos(x(1))) - p(1) ;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-sin(theta) * (sin(x(1)) - x(2) * x(1) * cos(x(1))) + ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cos(theta) * (cos(x(1)) + x(2) * x(1) * cos(x(1))) - p(2)];&lt;br&gt;
&lt;br&gt;
WORK SPACE:&lt;br&gt;
============&lt;br&gt;
theta=pi/4; p=[1;2];&lt;br&gt;
global theta p&lt;br&gt;
x0 = [0.7; 1];&lt;br&gt;
&lt;br&gt;
fsolve('findphi', x0)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Optimization terminated: first-order optimality is less than options.TolFun.&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.7848&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2.5462&lt;br&gt;
&lt;br&gt;
--Nasser </description>
    </item>
    <item>
      <pubDate>Tue, 03 Nov 2009 20:52:44 -0500</pubDate>
      <title>Re: how to solve a set of nonlinear equation systems with changing coefficients</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264861#691835</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;Nasser M. Abbasi&quot; &amp;lt;nma@12000.org&amp;gt; wrote in message &lt;br&gt;
news:gI0Im.789$fE2.146@newsfe04.iad...&lt;br&gt;
&lt;br&gt;
&amp;gt; theta=pi/4; p=[1;2];&lt;br&gt;
&amp;gt; global theta p&lt;br&gt;
&lt;br&gt;
Better to reverse the order above&lt;br&gt;
&lt;br&gt;
global theta p&lt;br&gt;
theta=pi/4; p=[1;2];&lt;br&gt;
&lt;br&gt;
--Nasser </description>
    </item>
  </channel>
</rss>

