<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603</link>
    <title>MATLAB Central Newsreader - Solving implicit solution</title>
    <description>Feed for thread: Solving implicit solution</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2013 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.ch/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 05 Feb 2012 15:07:10 +0000</pubDate>
      <title>Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865826</link>
      <author>Eng M </author>
      <description>I need to find d for the following code and i am getting an error, what is the problem?&lt;br&gt;
&lt;br&gt;
fy=40;&lt;br&gt;
cover=1.25;&lt;br&gt;
ql=1;&lt;br&gt;
for k=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Lx(k)=120+(k-1)*24;&lt;br&gt;
for l=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Ly(l)=120+(l-1)*24;&lt;br&gt;
for i=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cx(i)=8+(i-1)*4;&lt;br&gt;
for j=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cy(j)=8+(j-1)*4;&lt;br&gt;
&lt;br&gt;
if (Cx(i)&amp;gt;=Cy(j))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;B(i,j)=Cx(i)/Cy(j);&lt;br&gt;
else  B(i,j)=Cy(j)/Cx(i);&lt;br&gt;
end&lt;br&gt;
d=zeros([11 11 11 11]);&lt;br&gt;
A(i,j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(Cy(j)+d(i,j,k,l))))+2)&amp;lt;=4)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Vc(i,j,k,l)= ((40*d(i,j,k,l))/((2*(Cx(i)+d(i,j,k,l))+2*(Cy(j)+d(i,j,k,l))))+2);&lt;br&gt;
elseif (4&amp;lt;= ((40*d(i,j,k,l))/((2*(Cx(i)+d(i,j,k,l))+2*(Cy(j)+d(i,j,k,l))))+2)) &amp;&amp;  (4&amp;lt;=(2+4/B(i,j)))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Vc(i,j,k,l)= 4;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
end&lt;br&gt;
solve('delta1*6.4*ql*(Lx(k)*Ly(l)-(Cx(i)+d(i,j,k,l))*(Cy(j)+d(i,j,k,l)))/(d(i,j,k,l)*(2*Cx(i)+2*Cy(j)+4*d(i,j,k,l)))=Vc','d(i,j,k,l)');&lt;br&gt;
&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
a=reshape (A,14641,1);&lt;br&gt;
D=reshape (d,14641,1);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thank you in advance</description>
    </item>
    <item>
      <pubDate>Sun, 05 Feb 2012 19:34:10 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865835</link>
      <author>Roger Stafford</author>
      <description>"Eng M" wrote in message &amp;lt;jgm5ut$o0q$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I need to find d for the following code and i am getting an error, what is the problem?&lt;br&gt;
&amp;gt; solve('delta1*6.4*ql*(Lx(k)*Ly(l)-(Cx(i)+d(i,j,k,l))*(Cy(j)+d(i,j,k,l)))/(d(i,j,k,l)*(2*Cx(i)+2*Cy(j)+4*d(i,j,k,l)))=Vc','d(i,j,k,l)');&lt;br&gt;
- - - - - - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;That's just a quadratic equation in d.  Its coefficients are complicated but there is a simple formula for solving it learned by high school students.  Why are you using the sophisticated 'solve' for such an elementary purpose?&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Mon, 06 Feb 2012 14:46:10 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865890</link>
      <author>Eng M </author>
      <description>"Roger Stafford" wrote in message &amp;lt;jgmlji$98v$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Eng M" wrote in message &amp;lt;jgm5ut$o0q$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I need to find d for the following code and i am getting an error, what is the problem?&lt;br&gt;
&amp;gt; &amp;gt; solve('delta1*6.4*ql*(Lx(k)*Ly(l)-(Cx(i)+d(i,j,k,l))*(Cy(j)+d(i,j,k,l)))/(d(i,j,k,l)*(2*Cx(i)+2*Cy(j)+4*d(i,j,k,l)))=Vc','d(i,j,k,l)');&lt;br&gt;
&amp;gt; - - - - - - - - - - - - -&lt;br&gt;
&amp;gt;   That's just a quadratic equation in d.  Its coefficients are complicated but there is a simple formula for solving it learned by high school students.  Why are you using the sophisticated 'solve' for such an elementary purpose?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
--------------------------------------&lt;br&gt;
It is not quadratic equation where delta1 is also a function of d!!! and as you can see i have a function of d=minimum between 3 functions one of them also is a function of d !!!</description>
    </item>
    <item>
      <pubDate>Mon, 06 Feb 2012 17:29:09 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865906</link>
      <author>Roger Stafford</author>
      <description>"Eng M" wrote in message &amp;lt;jgop3i$nkq$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; It is not quadratic equation where delta1 is also a function of d!!! and as you can see i have a function of d=minimum between 3 functions one of them also is a function of d !!!&lt;br&gt;
- - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;As you have things set up, 'solve' thinks it is dealing with the equivalent of a quadratic equation.  It does not know about your apparent intent that G1, G2, delta1, and Vc should all vary as d varies.  In your code you have set d to zero in computing them.  These are the values 'solve' uses in attempting to derive a solution, not the variable values.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;It would be extremely difficult to express your problem in a form that would be suitable for 'solve', given the complexity I see here.  You should be using 'fzero' where provision is made for the functionality you have in mind.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;My apologies for my earlier, overly hasty analysis of your problem.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Mon, 06 Feb 2012 18:22:09 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865914</link>
      <author>Eng M </author>
      <description>"Roger Stafford" wrote in message &amp;lt;jgp2l5$spg$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Eng M" wrote in message &amp;lt;jgop3i$nkq$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; It is not quadratic equation where delta1 is also a function of d!!! and as you can see i have a function of d=minimum between 3 functions one of them also is a function of d !!!&lt;br&gt;
&amp;gt; - - - - - - - - -&lt;br&gt;
&amp;gt;   As you have things set up, 'solve' thinks it is dealing with the equivalent of a quadratic equation.  It does not know about your apparent intent that G1, G2, delta1, and Vc should all vary as d varies.  In your code you have set d to zero in computing them.  These are the values 'solve' uses in attempting to derive a solution, not the variable values.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   It would be extremely difficult to express your problem in a form that would be suitable for 'solve', given the complexity I see here.  You should be using 'fzero' where provision is made for the functionality you have in mind.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   My apologies for my earlier, overly hasty analysis of your problem.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
----------------------&lt;br&gt;
Thank you very much I tried to use fsolve but i am still getting errors:&lt;br&gt;
This is my new code i tried to combine all G1,G2, and delta 1 in one equation:&lt;br&gt;
&lt;br&gt;
fy=40;&lt;br&gt;
cover=1.25;&lt;br&gt;
ql=1;&lt;br&gt;
for k=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Lx(k)=120+(k-1)*24;&lt;br&gt;
for l=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Ly(l)=120+(l-1)*24;&lt;br&gt;
for i=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cx(i)=8+(i-1)*4;&lt;br&gt;
for j=1:11&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cy(j)=8+(j-1)*4;&lt;br&gt;
&lt;br&gt;
if (Cx(i)&amp;gt;=Cy(j))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;B(i,j)=Cx(i)/Cy(j);&lt;br&gt;
else  B(i,j)=Cy(j)/Cx(i);&lt;br&gt;
end&lt;br&gt;
A(i,j,k,l)=(Lx(k)+Ly(l))/(Cx(i)+Cy(j));&lt;br&gt;
&lt;br&gt;
fsolve(@(d)((1+((5/32)*((d*(Cx(i)+Cy(j)+2*d)/((Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))*(1+(3/2)*sqrt((Cy(j)+d)/(Cx(i)+d))))*0.336*Ly(l)*(Lx(k)-Cx(i))^2/(d^3+(Cx(i)+d)^2*d+3*d*(Cy(j)+d)*(Cx(i)+d)))+(d*(Cx(i)+Cy(j)+2*d)/((Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))*(1+(3/2)*sqrt((Cx(i)+d)/(Cy(j)+d))))*0.336*Lx(k)*(Ly(l)-Cy(j))^2/(d^3+(Cy(j)+d)^2*d+3*d*(Cx(i)+d)*(Cy(j)+d))))))*6.4*ql*(Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))/(d*(2*Cx(i)+2*Cy(j)+4*d))-min([2+4/B(i,j);(40*d)/((2*(Cx(i)+d)+2*(Cy(j)+d)))+2;4])),3);&lt;br&gt;
D=d(i,j,k,l);&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
a=reshape (A,14641,1);&lt;br&gt;
depth=reshape(D,14641,1);&lt;br&gt;
&lt;br&gt;
Could you please help me in this?&lt;br&gt;
Thank you in advance</description>
    </item>
    <item>
      <pubDate>Mon, 06 Feb 2012 19:43:11 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865921</link>
      <author>Roger Stafford</author>
      <description>"Eng M" wrote in message &amp;lt;jgp5oh$am9$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Thank you very much I tried to use fsolve but i am still getting errors:&lt;br&gt;
&amp;gt; This is my new code i tried to combine all G1,G2, and delta 1 in one equation:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fy=40;&lt;br&gt;
&amp;gt; cover=1.25;&lt;br&gt;
&amp;gt; ql=1;&lt;br&gt;
&amp;gt; for k=1:11&lt;br&gt;
&amp;gt;     Lx(k)=120+(k-1)*24;&lt;br&gt;
&amp;gt; for l=1:11&lt;br&gt;
&amp;gt;     Ly(l)=120+(l-1)*24;&lt;br&gt;
&amp;gt; for i=1:11&lt;br&gt;
&amp;gt;     Cx(i)=8+(i-1)*4;&lt;br&gt;
&amp;gt; for j=1:11&lt;br&gt;
&amp;gt;     Cy(j)=8+(j-1)*4;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; if (Cx(i)&amp;gt;=Cy(j))&lt;br&gt;
&amp;gt;     B(i,j)=Cx(i)/Cy(j);&lt;br&gt;
&amp;gt; else  B(i,j)=Cy(j)/Cx(i);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; A(i,j,k,l)=(Lx(k)+Ly(l))/(Cx(i)+Cy(j));&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fsolve(@(d)((1+((5/32)*((d*(Cx(i)+Cy(j)+2*d)/((Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))*(1+(3/2)*sqrt((Cy(j)+d)/(Cx(i)+d))))*0.336*Ly(l)*(Lx(k)-Cx(i))^2/(d^3+(Cx(i)+d)^2*d+3*d*(Cy(j)+d)*(Cx(i)+d)))+(d*(Cx(i)+Cy(j)+2*d)/((Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))*(1+(3/2)*sqrt((Cx(i)+d)/(Cy(j)+d))))*0.336*Lx(k)*(Ly(l)-Cy(j))^2/(d^3+(Cy(j)+d)^2*d+3*d*(Cx(i)+d)*(Cy(j)+d))))))*6.4*ql*(Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))/(d*(2*Cx(i)+2*Cy(j)+4*d))-min([2+4/B(i,j);(40*d)/((2*(Cx(i)+d)+2*(Cy(j)+d)))+2;4])),3);&lt;br&gt;
&amp;gt; D=d(i,j,k,l);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a=reshape (A,14641,1);&lt;br&gt;
&amp;gt; depth=reshape(D,14641,1);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Could you please help me in this?&lt;br&gt;
&amp;gt; Thank you in advance&lt;br&gt;
- - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;In the assignment "D=d(i,j,k,l)" it looks as if you have things backwards.  The quantity 'fsolve' (hopefully) solves will be a simple scalar quantity and matlab would not know what to do with something like d(i,j,k,l).  I think you should be writing "d(i,j,k,l)=D" with D being the variable solved for by 'solve'.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;A piece of advice:  When presenting a problem of this complex nature to this newsreader audience, you should reduce it to its simplest form.  Forget the fact that this is occurring within a set of nested for-loops, which has nothing to do with your difficulties, enabling you to leave out all the indices such as i in Cx(i) and just concentrate on the problem of solving a single implicit equation.  Try lumping the various known values together into single quantities to get as simple an expression as possible.  You could have left out altogether the computation of A which has nothing to do with your problem.  Also it is not necessary that we know the details of how Cx, Cy, and B are computed, but simply the fact that they are known.  Make it clear to us (and to 'solve') what your knowns and unknowns are to be.  Your original formulation of the input to 'solve' contained over a thousand &lt;br&gt;
characters and the more recent one is not much simpler, which is certainly discouraging to volunteers like myself with limited time and energy. &lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Mon, 06 Feb 2012 20:40:10 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865925</link>
      <author>Eng M </author>
      <description>"Roger Stafford" wrote in message &amp;lt;jgpagf$r51$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Eng M" wrote in message &amp;lt;jgp5oh$am9$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Thank you very much I tried to use fsolve but i am still getting errors:&lt;br&gt;
&amp;gt; &amp;gt; This is my new code i tried to combine all G1,G2, and delta 1 in one equation:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; fy=40;&lt;br&gt;
&amp;gt; &amp;gt; cover=1.25;&lt;br&gt;
&amp;gt; &amp;gt; ql=1;&lt;br&gt;
&amp;gt; &amp;gt; for k=1:11&lt;br&gt;
&amp;gt; &amp;gt;     Lx(k)=120+(k-1)*24;&lt;br&gt;
&amp;gt; &amp;gt; for l=1:11&lt;br&gt;
&amp;gt; &amp;gt;     Ly(l)=120+(l-1)*24;&lt;br&gt;
&amp;gt; &amp;gt; for i=1:11&lt;br&gt;
&amp;gt; &amp;gt;     Cx(i)=8+(i-1)*4;&lt;br&gt;
&amp;gt; &amp;gt; for j=1:11&lt;br&gt;
&amp;gt; &amp;gt;     Cy(j)=8+(j-1)*4;&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; if (Cx(i)&amp;gt;=Cy(j))&lt;br&gt;
&amp;gt; &amp;gt;     B(i,j)=Cx(i)/Cy(j);&lt;br&gt;
&amp;gt; &amp;gt; else  B(i,j)=Cy(j)/Cx(i);&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; A(i,j,k,l)=(Lx(k)+Ly(l))/(Cx(i)+Cy(j));&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; fsolve(@(d)((1+((5/32)*((d*(Cx(i)+Cy(j)+2*d)/((Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))*(1+(3/2)*sqrt((Cy(j)+d)/(Cx(i)+d))))*0.336*Ly(l)*(Lx(k)-Cx(i))^2/(d^3+(Cx(i)+d)^2*d+3*d*(Cy(j)+d)*(Cx(i)+d)))+(d*(Cx(i)+Cy(j)+2*d)/((Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))*(1+(3/2)*sqrt((Cx(i)+d)/(Cy(j)+d))))*0.336*Lx(k)*(Ly(l)-Cy(j))^2/(d^3+(Cy(j)+d)^2*d+3*d*(Cx(i)+d)*(Cy(j)+d))))))*6.4*ql*(Lx(k)*Ly(l)-(Cx(i)+d)*(Cy(j)+d))/(d*(2*Cx(i)+2*Cy(j)+4*d))-min([2+4/B(i,j);(40*d)/((2*(Cx(i)+d)+2*(Cy(j)+d)))+2;4])),3);&lt;br&gt;
&amp;gt; &amp;gt; D=d(i,j,k,l);&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; a=reshape (A,14641,1);&lt;br&gt;
&amp;gt; &amp;gt; depth=reshape(D,14641,1);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Could you please help me in this?&lt;br&gt;
&amp;gt; &amp;gt; Thank you in advance&lt;br&gt;
&amp;gt; - - - - - - - - -&lt;br&gt;
&amp;gt;   In the assignment "D=d(i,j,k,l)" it looks as if you have things backwards.  The quantity 'fsolve' (hopefully) solves will be a simple scalar quantity and matlab would not know what to do with something like d(i,j,k,l).  I think you should be writing "d(i,j,k,l)=D" with D being the variable solved for by 'solve'.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   A piece of advice:  When presenting a problem of this complex nature to this newsreader audience, you should reduce it to its simplest form.  Forget the fact that this is occurring within a set of nested for-loops, which has nothing to do with your difficulties, enabling you to leave out all the indices such as i in Cx(i) and just concentrate on the problem of solving a single implicit equation.  Try lumping the various known values together into single quantities to get as simple an expression as possible.  You could have left out altogether the computation of A which has nothing to do with your problem.  Also it is not necessary that we know the details of how Cx, Cy, and B are computed, but simply the fact that they are known.  Make it clear to us (and to 'solve') what your knowns and unknowns are to be.  Your original formulation of the input to 'solve' contained over a thousand &lt;br&gt;
&amp;gt; characters and the more recent one is not much simpler, which is certainly discouraging to volunteers like myself with limited time and energy. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
--------&lt;br&gt;
Thank you very much sir, and sorry for disturbance. This is the first time that i use this newsreader, and i just thought writing the whole code will make it easier to understand what i wanted excatly (to show that i want to find solution for function inside 4 loops). Thank you for your time and efford.</description>
    </item>
    <item>
      <pubDate>Tue, 07 Feb 2012 01:42:10 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#865939</link>
      <author>Roger Stafford</author>
      <description>"Eng M" wrote in message &amp;lt;jgpdra$9eg$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Thank you very much sir, and sorry for disturbance. This is the first time that i use this newsreader, and i just thought writing the whole code will make it easier to understand what i wanted excatly (to show that i want to find solution for function inside 4 loops). Thank you for your time and efford.&lt;br&gt;
- - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;I should point out that since both 'fsolve' and 'fzero' require an initial estimate be entered as an input, perhaps you can take advantage of one result to serve as a smart estimate for the next call.  This assumes that your Lx, Ly, Cx, and Cy values will not usually change very much from one time to another and therefore hopefully the solution would not change greatly.  This might save on execution time by avoiding wide swings in the solution search which these routines must perform.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;But of course before such a refinement you must first manage to get some one single solution.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Tue, 07 Feb 2012 14:43:09 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#866044</link>
      <author>Eng M </author>
      <description>"Roger Stafford" wrote in message &amp;lt;jgpvhi$4j9$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Eng M" wrote in message &amp;lt;jgpdra$9eg$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Thank you very much sir, and sorry for disturbance. This is the first time that i use this newsreader, and i just thought writing the whole code will make it easier to understand what i wanted excatly (to show that i want to find solution for function inside 4 loops). Thank you for your time and efford.&lt;br&gt;
&amp;gt; - - - - - - - - -&lt;br&gt;
&amp;gt;   I should point out that since both 'fsolve' and 'fzero' require an initial estimate be entered as an input, perhaps you can take advantage of one result to serve as a smart estimate for the next call.  This assumes that your Lx, Ly, Cx, and Cy values will not usually change very much from one time to another and therefore hopefully the solution would not change greatly.  This might save on execution time by avoiding wide swings in the solution search which these routines must perform.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   But of course before such a refinement you must first manage to get some one single solution.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
---------------------&lt;br&gt;
I am trying to define d as an array by many methods but still i am getting an error, it seems that to use 'fsolve' d should not be an array but a single value. So, what should I do to let it work in a loop?</description>
    </item>
    <item>
      <pubDate>Tue, 07 Feb 2012 17:35:10 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#866077</link>
      <author>Roger Stafford</author>
      <description>"Eng M" wrote in message &amp;lt;jgrd9t$q68$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I am trying to define d as an array by many methods but still i am getting an error, it seems that to use 'fsolve' d should not be an array but a single value. So, what should I do to let it work in a loop?&lt;br&gt;
- - - - - - - - - - - &lt;br&gt;
&amp;nbsp;&amp;nbsp;Yes you will need a loop eventually.  However, before bothering to write such a loop you need to concentrate on getting your code working for a single set of Cx, etc. values.  From what I can see you have not succeeded in that yet.  Using one set of Lx, Ly, Cx, and Cy values you need to coerce your code into producing a valid solution.  After that, putting it all in a loop is easy.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Tue, 07 Feb 2012 17:54:10 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#866083</link>
      <author>Eng M </author>
      <description>"Roger Stafford" wrote in message &amp;lt;jgrnce$2s6$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Eng M" wrote in message &amp;lt;jgrd9t$q68$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I am trying to define d as an array by many methods but still i am getting an error, it seems that to use 'fsolve' d should not be an array but a single value. So, what should I do to let it work in a loop?&lt;br&gt;
&amp;gt; - - - - - - - - - - - &lt;br&gt;
&amp;gt;   Yes you will need a loop eventually.  However, before bothering to write such a loop you need to concentrate on getting your code working for a single set of Cx, etc. values.  From what I can see you have not succeeded in that yet.  Using one set of Lx, Ly, Cx, and Cy values you need to coerce your code into producing a valid solution.  After that, putting it all in a loop is easy.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
-------------&lt;br&gt;
It is working for one set of Cx,Cy,Lx, and Ly, but it is not working when it comes to full set because fsolve is not working for multi-variables but only one set of Cx,Cy,Lx and Ly as you said!</description>
    </item>
    <item>
      <pubDate>Tue, 07 Feb 2012 18:14:09 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#866087</link>
      <author>Eng M </author>
      <description>"Eng M" wrote in message &amp;lt;jgrog2$6jt$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Roger Stafford" wrote in message &amp;lt;jgrnce$2s6$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; "Eng M" wrote in message &amp;lt;jgrd9t$q68$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; I am trying to define d as an array by many methods but still i am getting an error, it seems that to use 'fsolve' d should not be an array but a single value. So, what should I do to let it work in a loop?&lt;br&gt;
&amp;gt; &amp;gt; - - - - - - - - - - - &lt;br&gt;
&amp;gt; &amp;gt;   Yes you will need a loop eventually.  However, before bothering to write such a loop you need to concentrate on getting your code working for a single set of Cx, etc. values.  From what I can see you have not succeeded in that yet.  Using one set of Lx, Ly, Cx, and Cy values you need to coerce your code into producing a valid solution.  After that, putting it all in a loop is easy.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Roger Stafford&lt;br&gt;
&amp;gt; -------------&lt;br&gt;
&amp;gt; It is working for one set of Cx,Cy,Lx, and Ly, but it is not working when it comes to full set because fsolve is not working for multi-variables but only one set of Cx,Cy,Lx and Ly as you said!&lt;br&gt;
----------------------&lt;br&gt;
For single set i am getting the following:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Equation solved.&lt;br&gt;
&lt;br&gt;
fsolve completed because the vector of function values is near zero&lt;br&gt;
as measured by the default value of the function tolerance, and&lt;br&gt;
the problem appears regular as measured by the gradient.&lt;br&gt;
&lt;br&gt;
&amp;lt;stopping criteria details&amp;gt;</description>
    </item>
    <item>
      <pubDate>Mon, 20 Feb 2012 12:28:40 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#867238</link>
      <author>Christopher Creutzig</author>
      <description>On 05.02.12 16:07, Eng M wrote:&lt;br&gt;
&amp;gt; I need to find d for the following code and i am getting an error, what is the problem?&lt;br&gt;
&lt;br&gt;
&amp;gt; solve('delta1*6.4*ql*(Lx(k)*Ly(l)-(Cx(i)+d(i,j,k,l))*(Cy(j)+d(i,j,k,l)))/(d(i,j,k,l)*(2*Cx(i)+2*Cy(j)+4*d(i,j,k,l)))=Vc','d(i,j,k,l)');&lt;br&gt;
&lt;br&gt;
In addition to a number of things Roger already said: You are using&lt;br&gt;
strings in the input to solve. That means your values for Lx, Ly, etc.&lt;br&gt;
are not used.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Oh, and you didn't tell us which error you got. Typically, the error&lt;br&gt;
message contains at least an attempt at something helpful and they are&lt;br&gt;
often worth reading carefully.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Christopher</description>
    </item>
    <item>
      <pubDate>Tue, 21 Feb 2012 02:16:10 +0000</pubDate>
      <title>Re: Solving implicit solution</title>
      <link>http://www.mathworks.ch/matlabcentral/newsreader/view_thread/316603#867321</link>
      <author>Marc </author>
      <description>You were close, just a couple of formatting changes seem to get me an answer.&lt;br&gt;
&lt;br&gt;
I made the following changes to your previous code.... &lt;br&gt;
&lt;br&gt;
In the way beginning, before ANY looping, i would preallocate all of the vectors and arrays.  Also, set oldD = 3.;&lt;br&gt;
&lt;br&gt;
For fsolve, make sure to set the "display" option to off, otherwise you get 11^4 notifications.&lt;br&gt;
&lt;br&gt;
This took about 60 seconds.&lt;br&gt;
&lt;br&gt;
The one thing that I did not check was wether the way you have the anonymous function set up correctly.&lt;br&gt;
&lt;br&gt;
I wonder if Lx(i) and Ly(j)... etc. etc. in the function is changing.  &lt;br&gt;
&lt;br&gt;
There are several ways to check but I would double check that they are...&lt;br&gt;
&lt;br&gt;
Although this works, that function is painfully ugly... There has got to be a way to clean this up.&lt;br&gt;
&lt;br&gt;
clc&lt;br&gt;
clear&lt;br&gt;
tic&lt;br&gt;
fy=40;&lt;br&gt;
cover=1.25;&lt;br&gt;
ql=1;&lt;br&gt;
Lx = zeros(11,1);&lt;br&gt;
Ly = zeros(11,1);&lt;br&gt;
Cx = zeros(11,1);&lt;br&gt;
Cy = zeros(11,1);&lt;br&gt;
B = zeros(11,11);&lt;br&gt;
A = zeros(11,11,11,11); &lt;br&gt;
D = zeros(11,11,11,11);&lt;br&gt;
oldD = 3.;&lt;br&gt;
options = optimset('Display','off');&lt;br&gt;
for k=1:11&lt;br&gt;
%k = 1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Lx(k)=120+(k-1)*24;&lt;br&gt;
for l=1:11&lt;br&gt;
%l = 1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Ly(l)=120+(l-1)*24;&lt;br&gt;
for i=1:11&lt;br&gt;
%i = 1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cx(i)=8+(i-1)*4;&lt;br&gt;
for j=1:11&lt;br&gt;
%j = 1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Cy(j)=8+(j-1)*4;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l) = newD;&lt;br&gt;
oldD = newD;&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
toc</description>
    </item>
  </channel>
</rss>
