Path: news.mathworks.com!not-for-mail
From: "Md. Shahriar Karim" <karim.shahriar@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: dy/dt value from ode45 solver
Date: Thu, 20 Aug 2009 17:23:21 +0000 (UTC)
Organization: EBL
Lines: 79
Message-ID: <h6k0q9$9f5$1@fred.mathworks.com>
References: <h6f14q$7a7$1@fred.mathworks.com> <h6f5pa$hct$1@fred.mathworks.com> <h6fikv$egv$1@fred.mathworks.com> <h6firi$red$1@fred.mathworks.com> <h6h1q8$sp5$1@fred.mathworks.com> <h6jv5k$mfq$1@fred.mathworks.com>
Reply-To: "Md. Shahriar Karim" <karim.shahriar@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250789001 9701 172.30.248.38 (20 Aug 2009 17:23:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 20 Aug 2009 17:23:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1507044
Xref: news.mathworks.com comp.soft-sys.matlab:564825


Hi Steve, 

Thanks.

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--
***********************************************************
[t, y]=ode45('steadystate', [0:0.1:10000], y0);
%       dydt=steadystate(t,y);
plot(t, y)
xlabel('TIME'); ylabel('Concentration of Species in Molecules');
dydt=y;
for k=1:numel(t)
    dydt(k,:)=steadystate(t(k),y(k,:));
end
save dydt;
slopeC=dydt(:,2);
for i=1:numel(t)
    if (slopeC(i)<0.000001)
        time=t(i)
        break;
    end
************************************************

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?

Thanks,

Shahriar 


"Steven Lord" <slord@mathworks.com> wrote in message <h6jv5k$mfq$1@fred.mathworks.com>...
> 
> "Md. Shahriar Karim" <karim.shahriar@gmail.com> wrote in message 
> news:h6h1q8$sp5$1@fred.mathworks.com...
> > Hi Steve,
> >
> > Thanks for your help so far. However, I am totally unsure from the below 
> > part--
> >
> > Write a function to DEVAL the SOL struct array at a given time and 
> > subtract
> > that result from the desired dy/dt, then use FZERO on that function.
> >
> > sol=ode45(@steadystate, [0:0.1:10000], y0);
> >
> > once I do the above, I get my all variables value  after solving the 
> > ODEs..variables are..B C D ..etc.
> >
> > Now from this I am told to use the DEVAL   on "sol", it gives me the 
> > values of my variables B,C,D...but I was needed the "dy/dt...the slope 
> > values.
> >
> > Now, I am supposed to subtract my desired "dy/dt"..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.
> >
> > Could you please clarify how am I getting dy/dt out of the whole process? 
> > I am quite confused at this stage. Thanking you,
> 
> After reading Yi's response, I think I misread your question and I _think_ 
> it's simpler than I'm making it out to be, but I'm going to ask a 
> clarification question to make sure I understand what you're asking for.
> 
>     Are you trying to evaluate dy/dt at the times t and solution values y 
> returned by ODE45?
> 
> If so, just call your ODE function with those t and y inputs.  Depending on 
> how you wrote your ODE function, you may need to loop over the elements of 
> the time vector and the rows of the solution vector.  Remember, ODE45 
> requires a function that accepts t and y values and returns dy/dt evaluated 
> at those values -- which is precisely what I think you're looking for.
> 
> If that's not what you're looking for, please explain in a bit more depth 
> what you're trying to do.
> 
> -- 
> Steve Lord
> slord@mathworks.com 
>