solving the differential equation
显示 更早的评论
I want to solve the below equations. In these equations Q,Tp are variables, and italic underlined alphabets are constant. Also, Irr and Te are matrices with one row and 18 columns. I want to obtain Q and Tp as matrices with one row and 18 columns according to the amount of Irr and Te. I mean with the first element of Irr and Te, calculate the first elemnt of Tp and Q. My question is 'how can I solve these equations'? Would you please hep me?
dQ/dt=A * Irr + B * Te+ N Tp
if Q<C
Tp=D* Q
if E<Q<F
Tp=H
if Q>G
Tp=M* Q
4 个评论
Walter Roberson
2022-4-23
Duplicate question.
Sam Chak
2022-4-23
Hi Ms. @Hannah Mohebi
There seem to be multiple questions related to the same problem as listed below:
Can you consolidate them and advise which one should we answer?
To get meaningful answer (rather than letting us to guess), please provide the mathematical functions for the following:
Hannah Mohebi
2022-4-24
Walter Roberson
2022-4-25
As I described in https://www.mathworks.com/matlabcentral/answers/1702300-solve-the-system-of-linear-equation#comment_2118045 you will need to use one of the ode*() routines with Event Functions in order to detect the boundary conditions. You will need to have the event function fire in crossing either direction, because an increasing value for one component of the 1 x 18 Q might happen to be accompanied by a decreasing value for another. Any one component might happen to wander back and forth over a boundary while the other components are changing.
回答(1 个)
Sam Chak
2022-4-24
Hi Ms. @Hannah Mohebi
You did not specify what happen in these two regions
and
. Furthermore, no useful info about other parameters in your specific differential equation. Anyhow, if Tp looks like this:

then you can write the ODE as such (assuming that other parameters are constants, not matrices):
function dydt = Hannah(t, y)
dydt = zeros(1,1);
A = 1;
Irr = 1;
B = -1;
Te = 1;
N = -1;
D = 1;
E = -1;
F = 1;
M = 1;
Q = y;
Tp = min(max(0, M*Q - F), D*Q - E);
dydt = A*Irr + B*Te + N*Tp;
end
and solve it using ode45:
Tspan = [0 10]; % simulation time
y0 = -3:0.5:3; % initial value
[t, y] = ode45(@Hannah, Tspan, y0);
plot(t, y, 'linewidth', 1.5)
grid on
xlabel('Time, t')
ylabel('Q(t)')
Results:

1 个评论
Torsten
2022-4-24
But all variables involved (Q,Tp,Irr,Te) are 1x18, not 1x1.
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!