solving the differential equation

조회 수: 5 (최근 30일)
Hannah Mohebi
Hannah Mohebi 2022년 4월 22일
댓글: Walter Roberson 2022년 4월 25일
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
Torsten
Torsten 2022년 4월 22일
As already answered in a previous question, use ode45 or ode15s to solve for Q1,Q2,...Q18.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2022년 4월 22일
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
Torsten
Torsten 2022년 4월 23일
편집: Torsten 2022년 4월 23일
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
Walter Roberson 2022년 4월 25일
In later postings the dQ expressio got revised to not have the multiplication by Tp .

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by