<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816</link>
    <title>MATLAB Central Newsreader - dy/dt value from ode45 solver</title>
    <description>Feed for thread: dy/dt value from ode45 solver</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, 18 Aug 2009 19:58:18 -0400</pubDate>
      <title>dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674062</link>
      <author>Md. Shahriar Karim</author>
      <description>Hi, &lt;br&gt;
&lt;br&gt;
I just used ode45 to solve a set of differential equations and got value of my variables (say, y) plotted. How can I have the &quot;dy/dt&quot; value saved as well for each time step when I use ODE45 solver.&lt;br&gt;
&lt;br&gt;
Actually, I am interested to find out the steady-state time using the above approach. I consider &quot;dy/dt&quot; as a slope for the y plot and would like to extract the time value for any given condition on Slope dy/dt.&lt;br&gt;
&lt;br&gt;
Could you please suggest the way to save the dy/dt data value for ODE45 sovler?&lt;br&gt;
&lt;br&gt;
Thanking you&lt;br&gt;
&lt;br&gt;
Md. Shahriar Karim </description>
    </item>
    <item>
      <pubDate>Tue, 18 Aug 2009 20:21:15 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674069</link>
      <author>pavant</author>
      <description>On Aug 18, 3:58&#160;pm, &quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahr...@gmail.com&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I just used ode45 to solve a set of differential equations and got value of my variables (say, y) plotted. How can I have the &quot;dy/dt&quot; value saved as well for each time step when I use ODE45 solver.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Actually, I am interested to find out the steady-state time using the above approach. I consider &quot;dy/dt&quot; as a slope for the y plot and would like to extract the time value for any given condition on Slope dy/dt.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Could you please suggest the way to save the dy/dt data value for ODE45 sovler?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanking you&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Md. Shahriar Karim&lt;br&gt;
&lt;br&gt;
Hi,&lt;br&gt;
One solution is to double the dimension of your system. write down the&lt;br&gt;
eqns for d2y/dt2 also and append them to your state eqns.&lt;br&gt;
ex:&lt;br&gt;
&lt;br&gt;
if your original system is:&lt;br&gt;
&lt;br&gt;
dy/dt = -y;&lt;br&gt;
&lt;br&gt;
then d2y/dt2 = -dy/dt = y;&lt;br&gt;
&lt;br&gt;
then your system is:&lt;br&gt;
&lt;br&gt;
vdot = [-y; y];&lt;br&gt;
&lt;br&gt;
return vdot</description>
    </item>
    <item>
      <pubDate>Tue, 18 Aug 2009 21:17:36 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674081</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:h6f14q$7a7$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I just used ode45 to solve a set of differential equations and got value &lt;br&gt;
&amp;gt; of my variables (say, y) plotted. How can I have the &quot;dy/dt&quot; value saved &lt;br&gt;
&amp;gt; as well for each time step when I use ODE45 solver.&lt;br&gt;
&lt;br&gt;
Call ODE45 and specify some output arguments (one if you want the SOL &lt;br&gt;
solution struct array, two if you want t and y as individual vectors.)  Then &lt;br&gt;
plot the results (using DEVAL if you're using the SOL struct array.)&lt;br&gt;
&lt;br&gt;
&amp;gt; Actually, I am interested to find out the steady-state time using the &lt;br&gt;
&amp;gt; above approach. I consider &quot;dy/dt&quot; as a slope for the y plot and would &lt;br&gt;
&amp;gt; like to extract the time value for any given condition on Slope dy/dt.&lt;br&gt;
&lt;br&gt;
Write a function to DEVAL the SOL struct array at a given time and subtract &lt;br&gt;
that result from the desired dy/dt, then use FZERO on that function.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Wed, 19 Aug 2009 00:57:03 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674116</link>
      <author>Md. Shahriar Karim</author>
      <description>Hi Steve,&lt;br&gt;
&lt;br&gt;
DEVAL asks for a structure input. I also replaced &lt;br&gt;
&lt;br&gt;
[t, y]=ode45('steadystate', [0:0.1:10000], y0); part of my code  by &lt;br&gt;
sol=ode45('steadystate', [0:0.1:10000], y0);  &lt;br&gt;
&lt;br&gt;
but it didn't solve the problem. Again structure problem.&lt;br&gt;
&lt;br&gt;
My code works as follows--&lt;br&gt;
&lt;br&gt;
.......&lt;br&gt;
y0(1)=70; y0(2)=0; y0(3)=200;y0(4)=0; y0(5)=0;&lt;br&gt;
.......&lt;br&gt;
.......&lt;br&gt;
[t, y]=ode45('steadystate', [0:0.1:10000], y0); % I am calling another function &quot;steadystate&quot; %  &lt;br&gt;
or&lt;br&gt;
% sol=ode45('steadystate', [0:0.1:10000], y0);  &lt;br&gt;
&lt;br&gt;
function dydt = steadystate(t,y)&lt;br&gt;
......&lt;br&gt;
B  = y(1); C  = y(2); D = y(3);E  = y(4); M =y(5);&lt;br&gt;
......&lt;br&gt;
dydt(1)=... (differential Equation for B, C, D, E, M)&lt;br&gt;
dydt(2)=...&lt;br&gt;
.....&lt;br&gt;
.....&lt;br&gt;
dydt=dydt';&lt;br&gt;
&lt;br&gt;
My target is to calculate the dy/dt value for  variable &quot;C&quot;and once dy/dt value is available, I can put the checking condition for the slope calculation and find out my steady-state time accordingly.&lt;br&gt;
&lt;br&gt;
Please suggest something again. Thanks,&lt;br&gt;
&lt;br&gt;
Md. Shahriar Karim&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;h6f5pa$hct$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; news:h6f14q$7a7$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I just used ode45 to solve a set of differential equations and got value &lt;br&gt;
&amp;gt; &amp;gt; of my variables (say, y) plotted. How can I have the &quot;dy/dt&quot; value saved &lt;br&gt;
&amp;gt; &amp;gt; as well for each time step when I use ODE45 solver.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Call ODE45 and specify some output arguments (one if you want the SOL &lt;br&gt;
&amp;gt; solution struct array, two if you want t and y as individual vectors.)  Then &lt;br&gt;
&amp;gt; plot the results (using DEVAL if you're using the SOL struct array.)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Actually, I am interested to find out the steady-state time using the &lt;br&gt;
&amp;gt; &amp;gt; above approach. I consider &quot;dy/dt&quot; as a slope for the y plot and would &lt;br&gt;
&amp;gt; &amp;gt; like to extract the time value for any given condition on Slope dy/dt.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Write a function to DEVAL the SOL struct array at a given time and subtract &lt;br&gt;
&amp;gt; that result from the desired dy/dt, then use FZERO on that function.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Steve Lord&lt;br&gt;
&amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Wed, 19 Aug 2009 01:00:41 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674119</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:h6fikv$egv$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi Steve,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; DEVAL asks for a structure input. I also replaced&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; [t, y]=ode45('steadystate', [0:0.1:10000], y0); part of my code  by&lt;br&gt;
&amp;gt; sol=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
&lt;br&gt;
Try replacing the string input with a function handle to your function and &lt;br&gt;
use the second of those syntaxes..&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Wed, 19 Aug 2009 14:22:00 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674235</link>
      <author>Md. Shahriar Karim</author>
      <description>Hi Steve,&lt;br&gt;
&lt;br&gt;
Thanks for your help so far. However, I am totally unsure from the below part--&lt;br&gt;
&lt;br&gt;
Write a function to DEVAL the SOL struct array at a given time and subtract &lt;br&gt;
that result from the desired dy/dt, then use FZERO on that function.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;sol=ode45(@steadystate, [0:0.1:10000], y0);&lt;br&gt;
&lt;br&gt;
once I do the above, I get my all variables value  after solving the ODEs..variables are..B C D ..etc.&lt;br&gt;
&lt;br&gt;
Now from this I am told to use the DEVAL   on &quot;sol&quot;, it gives me the values of my variables B,C,D...but I was needed the &quot;dy/dt...the slope values.  &lt;br&gt;
&lt;br&gt;
Now, I am supposed to subtract my desired &quot;dy/dt&quot;..say 0.00001 from DEVAL output which is my variables values? Once this is done, I do FZERO on the result I get after subtraction....this is what I was told.&lt;br&gt;
&lt;br&gt;
Could you please clarify how am I getting dy/dt out of the whole process? I am quite confused at this stage. Thanking you,&lt;br&gt;
&lt;br&gt;
Md. Shahriar Karim&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;h6firi$red$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; news:h6fikv$egv$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; Hi Steve,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; DEVAL asks for a structure input. I also replaced&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; [t, y]=ode45('steadystate', [0:0.1:10000], y0); part of my code  by&lt;br&gt;
&amp;gt; &amp;gt; sol=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Try replacing the string input with a function handle to your function and &lt;br&gt;
&amp;gt; use the second of those syntaxes..&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Steve Lord&lt;br&gt;
&amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Wed, 19 Aug 2009 18:39:03 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674311</link>
      <author>Yi Cao</author>
      <description>&quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &amp;lt;h6h1q8$sp5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Steve,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for your help so far. However, I am totally unsure from the below part--&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Write a function to DEVAL the SOL struct array at a given time and subtract &lt;br&gt;
&amp;gt; that result from the desired dy/dt, then use FZERO on that function.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  sol=ode45(@steadystate, [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; once I do the above, I get my all variables value  after solving the ODEs..variables are..B C D ..etc.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Now from this I am told to use the DEVAL   on &quot;sol&quot;, it gives me the values of my variables B,C,D...but I was needed the &quot;dy/dt...the slope values.  &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Now, I am supposed to subtract my desired &quot;dy/dt&quot;..say 0.00001 from DEVAL output which is my variables values? Once this is done, I do FZERO on the result I get after subtraction....this is what I was told.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Could you please clarify how am I getting dy/dt out of the whole process? I am quite confused at this stage. Thanking you,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Md. Shahriar Karim&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;h6firi$red$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;gt; news:h6fikv$egv$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi Steve,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; DEVAL asks for a structure input. I also replaced&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; [t, y]=ode45('steadystate', [0:0.1:10000], y0); part of my code  by&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; sol=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Try replacing the string input with a function handle to your function and &lt;br&gt;
&amp;gt; &amp;gt; use the second of those syntaxes..&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; -- &lt;br&gt;
&amp;gt; &amp;gt; Steve Lord&lt;br&gt;
&amp;gt; &amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&lt;br&gt;
Actually, after you got the solution to the ODE, just call the function again you can get dy/dt, i.e.&lt;br&gt;
&lt;br&gt;
[t, y]=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
dydt = steadystate(t,y);  %if your function is vectorized. Alternatively&lt;br&gt;
&lt;br&gt;
dydt=y;&lt;br&gt;
for k=1:numel(t)&lt;br&gt;
&amp;nbsp;dydt(k,:)=steadystate(t(k),y(k,:));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
HTH&lt;br&gt;
Yi</description>
    </item>
    <item>
      <pubDate>Thu, 20 Aug 2009 04:09:03 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674429</link>
      <author>Md. Shahriar Karim</author>
      <description>Hi Cao,&lt;br&gt;
&lt;br&gt;
Could you please explain the logic working here? Once I call the function again how does it give the dydt value? &lt;br&gt;
&lt;br&gt;
is it that if I call the function again, it's going to give us the value of dy2dt2?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Md. Shahriar Karim&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Yi Cao&quot; &amp;lt;y.cao@cranfield.ac.uk&amp;gt; wrote in message &amp;lt;h6hgs7$9uf$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &amp;lt;h6h1q8$sp5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi Steve,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks for your help so far. However, I am totally unsure from the below part--&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Write a function to DEVAL the SOL struct array at a given time and subtract &lt;br&gt;
&amp;gt; &amp;gt; that result from the desired dy/dt, then use FZERO on that function.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;  sol=ode45(@steadystate, [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; once I do the above, I get my all variables value  after solving the ODEs..variables are..B C D ..etc.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Now from this I am told to use the DEVAL   on &quot;sol&quot;, it gives me the values of my variables B,C,D...but I was needed the &quot;dy/dt...the slope values.  &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Now, I am supposed to subtract my desired &quot;dy/dt&quot;..say 0.00001 from DEVAL output which is my variables values? Once this is done, I do FZERO on the result I get after subtraction....this is what I was told.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Could you please clarify how am I getting dy/dt out of the whole process? I am quite confused at this stage. Thanking you,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Md. Shahriar Karim&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;h6firi$red$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; news:h6fikv$egv$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi Steve,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; DEVAL asks for a structure input. I also replaced&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; [t, y]=ode45('steadystate', [0:0.1:10000], y0); part of my code  by&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; sol=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Try replacing the string input with a function handle to your function and &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; use the second of those syntaxes..&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; -- &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Steve Lord&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Actually, after you got the solution to the ODE, just call the function again you can get dy/dt, i.e.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [t, y]=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; dydt = steadystate(t,y);  %if your function is vectorized. Alternatively&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; dydt=y;&lt;br&gt;
&amp;gt; for k=1:numel(t)&lt;br&gt;
&amp;gt;  dydt(k,:)=steadystate(t(k),y(k,:));&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; HTH&lt;br&gt;
&amp;gt; Yi</description>
    </item>
    <item>
      <pubDate>Thu, 20 Aug 2009 16:55:24 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674594</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:h6h1q8$sp5$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi Steve,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks for your help so far. However, I am totally unsure from the below &lt;br&gt;
&amp;gt; part--&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Write a function to DEVAL the SOL struct array at a given time and &lt;br&gt;
&amp;gt; subtract&lt;br&gt;
&amp;gt; that result from the desired dy/dt, then use FZERO on that function.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sol=ode45(@steadystate, [0:0.1:10000], y0);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; once I do the above, I get my all variables value  after solving the &lt;br&gt;
&amp;gt; ODEs..variables are..B C D ..etc.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Now from this I am told to use the DEVAL   on &quot;sol&quot;, it gives me the &lt;br&gt;
&amp;gt; values of my variables B,C,D...but I was needed the &quot;dy/dt...the slope &lt;br&gt;
&amp;gt; values.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Now, I am supposed to subtract my desired &quot;dy/dt&quot;..say 0.00001 from DEVAL &lt;br&gt;
&amp;gt; output which is my variables values? Once this is done, I do FZERO on the &lt;br&gt;
&amp;gt; result I get after subtraction....this is what I was told.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Could you please clarify how am I getting dy/dt out of the whole process? &lt;br&gt;
&amp;gt; I am quite confused at this stage. Thanking you,&lt;br&gt;
&lt;br&gt;
After reading Yi's response, I think I misread your question and I _think_ &lt;br&gt;
it's simpler than I'm making it out to be, but I'm going to ask a &lt;br&gt;
clarification question to make sure I understand what you're asking for.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Are you trying to evaluate dy/dt at the times t and solution values y &lt;br&gt;
returned by ODE45?&lt;br&gt;
&lt;br&gt;
If so, just call your ODE function with those t and y inputs.  Depending on &lt;br&gt;
how you wrote your ODE function, you may need to loop over the elements of &lt;br&gt;
the time vector and the rows of the solution vector.  Remember, ODE45 &lt;br&gt;
requires a function that accepts t and y values and returns dy/dt evaluated &lt;br&gt;
at those values -- which is precisely what I think you're looking for.&lt;br&gt;
&lt;br&gt;
If that's not what you're looking for, please explain in a bit more depth &lt;br&gt;
what you're trying to do.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Thu, 20 Aug 2009 17:23:21 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674605</link>
      <author>Md. Shahriar Karim</author>
      <description>Hi Steve, &lt;br&gt;
&lt;br&gt;
Thanks.&lt;br&gt;
&lt;br&gt;
I need dy/dt value from a set of ODE. y value is not mandatory for me. however, it's okay if I have those. I have coded it in following manner--&lt;br&gt;
***********************************************************&lt;br&gt;
[t, y]=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
%       dydt=steadystate(t,y);&lt;br&gt;
plot(t, y)&lt;br&gt;
xlabel('TIME'); ylabel('Concentration of Species in Molecules');&lt;br&gt;
dydt=y;&lt;br&gt;
for k=1:numel(t)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dydt(k,:)=steadystate(t(k),y(k,:));&lt;br&gt;
end&lt;br&gt;
save dydt;&lt;br&gt;
slopeC=dydt(:,2);&lt;br&gt;
for i=1:numel(t)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (slopeC(i)&amp;lt;0.000001)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;time=t(i)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
************************************************&lt;br&gt;
&lt;br&gt;
But I am not yet clear how the calling of steadystate function is giving me the data dy/dt? Could you please explain a little bit?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Shahriar &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;h6jv5k$mfq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; news:h6h1q8$sp5$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; Hi Steve,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thanks for your help so far. However, I am totally unsure from the below &lt;br&gt;
&amp;gt; &amp;gt; part--&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Write a function to DEVAL the SOL struct array at a given time and &lt;br&gt;
&amp;gt; &amp;gt; subtract&lt;br&gt;
&amp;gt; &amp;gt; that result from the desired dy/dt, then use FZERO on that function.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; sol=ode45(@steadystate, [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; once I do the above, I get my all variables value  after solving the &lt;br&gt;
&amp;gt; &amp;gt; ODEs..variables are..B C D ..etc.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Now from this I am told to use the DEVAL   on &quot;sol&quot;, it gives me the &lt;br&gt;
&amp;gt; &amp;gt; values of my variables B,C,D...but I was needed the &quot;dy/dt...the slope &lt;br&gt;
&amp;gt; &amp;gt; values.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Now, I am supposed to subtract my desired &quot;dy/dt&quot;..say 0.00001 from DEVAL &lt;br&gt;
&amp;gt; &amp;gt; output which is my variables values? Once this is done, I do FZERO on the &lt;br&gt;
&amp;gt; &amp;gt; result I get after subtraction....this is what I was told.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Could you please clarify how am I getting dy/dt out of the whole process? &lt;br&gt;
&amp;gt; &amp;gt; I am quite confused at this stage. Thanking you,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; After reading Yi's response, I think I misread your question and I _think_ &lt;br&gt;
&amp;gt; it's simpler than I'm making it out to be, but I'm going to ask a &lt;br&gt;
&amp;gt; clarification question to make sure I understand what you're asking for.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;     Are you trying to evaluate dy/dt at the times t and solution values y &lt;br&gt;
&amp;gt; returned by ODE45?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If so, just call your ODE function with those t and y inputs.  Depending on &lt;br&gt;
&amp;gt; how you wrote your ODE function, you may need to loop over the elements of &lt;br&gt;
&amp;gt; the time vector and the rows of the solution vector.  Remember, ODE45 &lt;br&gt;
&amp;gt; requires a function that accepts t and y values and returns dy/dt evaluated &lt;br&gt;
&amp;gt; at those values -- which is precisely what I think you're looking for.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If that's not what you're looking for, please explain in a bit more depth &lt;br&gt;
&amp;gt; what you're trying to do.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Steve Lord&lt;br&gt;
&amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Thu, 20 Aug 2009 17:28:10 -0400</pubDate>
      <title>Re: dy/dt value from ode45 solver</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258816#674609</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Md. Shahriar Karim&quot; &amp;lt;karim.shahriar@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:h6k0q9$9f5$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Hi Steve,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I need dy/dt value from a set of ODE. y value is not mandatory for me. &lt;br&gt;
&amp;gt; however, it's okay if I have those. I have coded it in following manner--&lt;br&gt;
&amp;gt; ***********************************************************&lt;br&gt;
&amp;gt; [t, y]=ode45('steadystate', [0:0.1:10000], y0);&lt;br&gt;
&amp;gt; %       dydt=steadystate(t,y);&lt;br&gt;
&amp;gt; plot(t, y)&lt;br&gt;
&amp;gt; xlabel('TIME'); ylabel('Concentration of Species in Molecules');&lt;br&gt;
&amp;gt; dydt=y;&lt;br&gt;
&amp;gt; for k=1:numel(t)&lt;br&gt;
&amp;gt;    dydt(k,:)=steadystate(t(k),y(k,:));&lt;br&gt;
&amp;gt; end&lt;br&gt;
&lt;br&gt;
*snip*&lt;br&gt;
&lt;br&gt;
&amp;gt; But I am not yet clear how the calling of steadystate function is giving &lt;br&gt;
&amp;gt; me the data dy/dt? Could you please explain a little bit?&lt;br&gt;
&lt;br&gt;
Remember, as stated in the documentation for ODE45, the first input argument &lt;br&gt;
that it requires is a function that accepts two inputs, t and y, and returns &lt;br&gt;
the right-hand side of the system of differential equations y' = dy/dt = &lt;br&gt;
f(t, y).  Thus the values from that function _are_ the dy/dt values you're &lt;br&gt;
looking for.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
  </channel>
</rss>

