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 Comments

Duplicate question.
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:
I tried to explain my problem in different ways, so I asked different questions, and I did not get any helpful answers until now. This is my exact question; please answer this question. As I explained in the question, italic underlined alphabets are constant. Therefore D, H, and M are constant, not a function of t, Q.
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.

Sign in to comment.

Answers (1)

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 Comment

But all variables involved (Q,Tp,Irr,Te) are 1x18, not 1x1.

Sign in to comment.

Products

Release

R2020a

Asked:

on 23 Apr 2022

Commented:

on 25 Apr 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!