How to code a couple ODE with nodes
Show older comments
Hello everyone. I am trying to model a thermal system. It is a system of the equation that must be solved:

Xi and Yi are the temperatures at a hypothetical element. (i-1) and (i+1) refer to the previous and next node and A to G are some known coefficients. I consider the ode45 to solve these coupled equations, but the problem is with defining a new parameter such as Z to involve both X and Y, how the nodes (i-1 i i+1) be considered?
Can the following code be run with a few changes?
function zprime = myfun(t,z);
zprime=[A*x(1)(i) + B*x(1)(i-1) + C*x(1)(i+1) + D*x(2)(i) ; E*x(2)(i) + F*x(2)(i-1) + G*x(1)(i)]; % This is absoloutly wrong call!
z0=[a b];
tspan=[0,20];
[t,x]=ode45(@myfun,tspan,z0);
Many thanks!
Accepted Answer
More Answers (1)
ehsan rezaei
on 5 Feb 2022
0 votes
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!