Problem with ode45
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!