solving the differential equation
5 views (last 30 days)
Show older comments
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. My question is 'how can I solve these equations'?
dQ/dt=A * Irr * Tp + B * Te * Tp
if Q<C
Tp=D* Q
if E<Q<F
Tp=H
if Q>G
Tp=M* Q
1 Comment
Torsten
on 22 Apr 2022
As already answered in a previous question, use ode45 or ode15s to solve for Q1,Q2,...Q18.
Answers (1)
Walter Roberson
on 22 Apr 2022
Your system cannot work.
dQ/dt=A * Irr * Tp + B * Te * Tp
You say that Irr and Te are matrices with one row and 18 columns. If, hypothetically, Tp was scalar, then dQ/dt would be the sum of two expressions that were each 1 x 18 and the result would be 1 x 18, which would be (locally) self-consistent so far.
Then you reach the if and you see the first branch and last branch assign Tp = constant times Q. But Q is 1 x 18, so Tp would have to be 1 x 18, contradicting the assumption that Tp is scalar.
So we have to go back to
dQ/dt=A * Irr * Tp + B * Te * Tp
this time with the assumption that irr and Te and Tp are each 1 x 18. But you have Irr * Tp and that is a (1 x 18) * a (1 x 18). Which is an invalid operation, inner product between two row vectors.
You cannot get the correct sizes out unless you use element-by-element multiplication, .* instead of inner product, *
2 Comments
Torsten
on 23 Apr 2022
Edited: Torsten
on 23 Apr 2022
For Q, Tp, Irr and Te being 1x18 and elementwise multiplication in
dQ/dt=A * Irr .* Tp + B * Te .* Tp
the if-statement could be interpreted elementwise:
if Q(i)<C
Tp(i)=D* Q(i)
if E<Q(i)<F
Tp(i)=H
if Q(i)>G
Tp(i)=M* Q(i)
(1<=i<=18)
At least this is the only interpretation that makes sense.
Walter Roberson
on 25 Apr 2022
In later postings the dQ expressio got revised to not have the multiplication by Tp .
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!