Afficher commentaires plus anciens
I need to find the general solution of multiple x functions from stiff differential equations. I am using ode45 however my code is not plotting the graphs as it is giving me the "Error updating FunctionLine" warning, I am unsure how to fix this issue, as this is my first time using ode45. Please let me know where is it causing a issue and how i can overcome it.
cons = [con1,con2,con3];
tspan = [0 5];
[t,x] = ode45(@(t,x)odefcn(t,x1,x2,x3), tspan, cons);
fplot(x1,[0,5],'color','c')
hold on
fplot(x2,[0,5],'color','m')
hold on
fplot(x3,[0,5],'color','k')
xlabel('time/(t)')
ylabel('Amount of water/x(t)')
legend({'x1(t)','x2(t)','x3(t)'},'Location','southeast')
function dxdt = odefcn(t,x1,x2,x3)
dxdt = zeros(3,1);
dx1 = 1/3*x3(t) - 1/2*x1(t);
dx2 = 1/2*x1(t) - 1/2*x2(t);
dx3 = 1/2*x2(t) - 1/3*x3(t);
end
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!