ode15s with vectorized code
- From: "Urs Stöcker" <ustoecker@xxxxxxxxxxxxxx>
- Date: Mon, 17 Oct 2005 16:31:48 -0400
Hello
I'm struggling right now with some code concerning a stiff ode. My
code evaluates the differential equation vectorized, meaning:
dydt=f(t,y) is a column vector of the same size as the input vector
y. The initial condition y0 is a vector of this size too.
Anyway after the second time calling the odefun-function y is a
square matrix of size [length(y0),length(y0)]. Can anybody tell me
why this happens and what I've done wrong?
Thanks for your reply in advance!
Some more details of the code:
I have an equation of the form:
dndt+dndx*dxdt=f(x)*(1-n)-g(x)*n, while n=n(x,t)
I transform the equation with chi=x+L into a space where the dxdt
term falls out. So I get:
dpdt=f(chi)*(1-p)-g(chi)*p with p=n(chi,t)
so I call the ode-solver:
%mycode for ode15s:
%-----------------
%main body
my_options = odeset('OutputFcn',@odeplot, 'Vectorized', 'on');
[t,n]=ode15s(@diffct, [0,5], p0, my_options, @t, x, @f,@g);
%-----------------
%odefun for my problem
function dpdt=diffct(t,p, trans, x, f_func, g_func)
chi=feval(trans,x,t);
one_vector=ones(size(chi));
dpdt=(feval(f_func,chi).*(one_vector-p)-feval(g_func, chi).*p);
%-----------------
%transformation for a discrete t and x-vector
function chi=trans(x,t);
tspan=(t-1):0.001:(t+1);
L=length_profile(tspan);
L_t=interp1(tspan, L, t, 'spline');%BTW:does this go nicer?
chi=x+L_t;
.
- Follow-Ups:
- Re: ode15s with vectorized code
- From: Jacek Kierzenka
- Re: ode15s with vectorized code
- Prev by Date: Re: Error at executing MATLAB 7.0 (auto-closing)
- Next by Date: Re: DELETE & invalid handle object
- Previous by thread: change transfer function automatically
- Next by thread: Re: ode15s with vectorized code
- Index(es):
Relevant Pages
|