Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to use ode() solver

1 visualizzazione (ultimi 30 giorni)
John Miller
John Miller il 24 Giu 2012
Chiuso: MATLAB Answer Bot il 20 Ago 2021
Hello, I have following code:
ftod_sym=detofJac(doy); %here I calculate my symbolic vectorfield ftod_sym which is a function of y1 y2 and t
myfun = matlabFunction(ftod_sym); %conversion
[T N]=ode15s(@(y,t)myfun,tspan,n0,optionsO); % n0 is a vector with 2 elements
I get following ERROR:
Error using odearguments (line 93)
@(Y,T)MYFUN returns a vector of length 1, but the length of initial conditions vector is 2. The vector returned
by @(Y,T)MYFUN and the initial conditions vector must have the same number of elements.
Error in ode15s (line 149)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in flipflop_NR (line 46)
[T N]=ode15s(@(y,t)myfun,tspan,n0,optionsO);
Thank You

Risposte (1)

Walter Roberson
Walter Roberson il 24 Giu 2012
[T N]=ode15s(myfun,tspan,n0,optionsO);
You were not passing y and t to myfun, so you were not getting back the output you were expecting.
  5 Commenti
Walter Roberson
Walter Roberson il 24 Giu 2012
Use subscripting of "y" right in your symbolic expression, and then just use myfun as the function handle.
John Miller
John Miller il 24 Giu 2012
For my symbolic expression I need for example the symbolic jacobian. What I do is:
y=sym('y',[2 1]);
syms t
f_algebraic=ALG_y(t,y); %my function
J = jacobian(f_algebraic, y);
I dont know how to do in another way...
Hope somone can help
Thank you

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by