Error using ode45 - Column vector
Afficher commentaires plus anciens
Hi, I have this error:
Error using odearguments (line 90)
@(T,P)('FUN1') must return a column vector.
But the function returns a column vector. Can anyone help me find my mistake? I have read the other questions people have asked on this and they were all entering row vectors. Here is my code:
The function:
function f = fun1(t,P)
f = zeros(3,1);
f(1) = -1.92*P(1);
f(2) = 1.92*P(1)-1.2*P(2);
f(3) = 1.2*P(2);
end
The code which uses the function:
dPdt = @(t,P)('fun1');
P0 = [1,0,0];
[t,P] = ode45(dPdt, [0 5], P0);
plot(t, P)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!