필터 지우기
필터 지우기

Tranform a systems of equations to for loop

조회 수: 3 (최근 30일)
letoppina
letoppina 2021년 3월 18일
댓글: Walter Roberson 2021년 3월 31일
Hello everyone, I hav the following systems of equations:
syms Qc Qh Qm1 Qm2 Qm3 T1 T2 T3
eqn1 = Qm1 - Qc == q0 - Pc - qw/2 ;
eqn2 = T1 + Rc*Qc == T0;
eqn3 = T2 - T1 + R1/2*Qm1 == R1/2*q0;
eqn4 = T2 - Rg0/2*Qm1 + Rg0/2*Qm2 == T0;
eqn5 = T3 - T2 + R1/2*Qm2 == R1/2*q0;
eqn6 = T3 - Rg0/2*Qm2 + Rg0/2*Qm3 == T0;
eqn7 = Qh + Qm3 == Ph - q0 + qw/2;
eqn8 = T3 - Rh*Qh == T0;
[A,B] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8], [Qc Qh Qm1 Qm2 Qm3 T1 T2 T3]);
X = linsolve(A,B);
Is there a way to transform these systems of equations to a simpler and faster way to calculate the unknwowns variables (like a for loop)?
Thanks in advance!

답변 (1개)

Walter Roberson
Walter Roberson 2021년 3월 18일
No, linsolve is pretty efficient.
  댓글 수: 4
letoppina
letoppina 2021년 3월 31일
Could you show me how to code it? I am a beginner in matlab
Walter Roberson
Walter Roberson 2021년 3월 31일
q0vals = [-1, 0, 1];
syms Pc Ph q0 qw R1 Rc Rg0 Rh T0 %replace these with actual constants
syms Qc Qh Qm1 Qm2 Qm3 T1 T2 T3
eqn1 = Qm1 - Qc == q0 - Pc - qw/2 ;
eqn2 = T1 + Rc*Qc == T0;
eqn3 = T2 - T1 + R1/2*Qm1 == R1/2*q0;
eqn4 = T2 - Rg0/2*Qm1 + Rg0/2*Qm2 == T0;
eqn5 = T3 - T2 + R1/2*Qm2 == R1/2*q0;
eqn6 = T3 - Rg0/2*Qm2 + Rg0/2*Qm3 == T0;
eqn7 = Qh + Qm3 == Ph - q0 + qw/2;
eqn8 = T3 - Rh*Qh == T0;
[A,B] = equationsToMatrix([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8], [Qc Qh Qm1 Qm2 Qm3 T1 T2 T3]);
Bmat = subs(B, q0, q0vals)
Bmat = 
X = simplify(A\Bmat);
X
X = 

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

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by