ode15s

조회 수: 12 (최근 30일)
ahmad
ahmad 2012년 1월 30일
Solving a partial differential equation with ode15s,we know that this ode solver integrates the ode over time direvatives.I need to find the values of these time direvatives,do you have any special command? for example: for i=1:n dudt=uxx(i) end
how can I find these dudt at each time and x(i)? thanks alot

채택된 답변

Andrew Newell
Andrew Newell 2012년 1월 30일
If you are solving something like
[t,x] = solver(odefun,tspan,y0)
and you want the time derivative at each point t(i), then that is simply
dxdt = 0*x; % initialize the array
for ii=1:length(t)
dxdt(ii,:) = odefun(t(ii),x(ii,:));
end
(edited to allow for the possibility that x has more than one component at each time t).
  댓글 수: 2
Bård Skaflestad
Bård Skaflestad 2012년 1월 30일
That's more or less what I had in mind. Calling the |odefun| from an |OutputFcn| is just another refinement.
ahmad
ahmad 2012년 2월 20일
So if I want to calculate the integral of square of dudt i don't have any special command in my mind,in fact I used trapz but it keeps saying "the length of x should be the same as the first non-singleton variable" or it says that "x should be a vector".

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Bård Skaflestad
Bård Skaflestad 2012년 1월 30일
If you're going to solve a PDE by the method of lines (i.e., converting it into a system of ODEs), then you will need to provide a spatial discretisation of the PDE along with suitable initial conditions whence ode15s (or others) will likely assist you in the numerical solution.
Please review your favourite text book on discretisation methods.
  댓글 수: 4
Bård Skaflestad
Bård Skaflestad 2012년 1월 30일
Sorry, I meant |odeset|, not |optimset|.
ahmad
ahmad 2012년 1월 30일
I think that you are good at matlab numerical processes,can you please take a look at my program?I need to call the du/dt values solved by ode solver at every point like du/dt(t,x),is there a special command for it?it is true that its a big amount of data.so how can i do the other calculations using these values?
thanks

댓글을 달려면 로그인하십시오.


Andrew Newell
Andrew Newell 2012년 1월 30일
You could use deval.
EDIT: Here is a modified version of the example at the link provided:
sol = ode45(@vdp1,[0 20],[2 0]);
t = linspace(0,20,100);
[y,dy] = deval(sol,t,1);
plot(t,dy);
  댓글 수: 3
Andrew Newell
Andrew Newell 2012년 1월 30일
I think it is the time derivative (as in the example I added), but for a polynomial fitting the solution. I provide a more direct solution in a separate answer.
Bård Skaflestad
Bård Skaflestad 2012년 1월 30일
Indeed it is. The second output of |deval| is the derivative (wrt the independent variable) of the continuous output polynomial fitted to the numerical scheme of the particular solver (ODE45 in the above example).
Yet another detail I'd missed while skimming the documentation of |deval|.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by