필터 지우기
필터 지우기

How to solve parametric simultaneous equations in MATLAB?

조회 수: 3 (최근 30일)
Ryan Rizzo
Ryan Rizzo 2018년 10월 27일
댓글: Walter Roberson 2018년 10월 27일
I have three parametric simultaneous equations as follows:
I*R + L*s*I + a*s*Y - V = 0
B*I + m*s^2*Y - k2*X + k2*Y - b2*s*X + b2*s*Y = 0
-B*I + M*s^2*X + (b1 + b2)*s*X - b2*s*Y + (k1+k2)*X - k2*Y = 0
I am trying to solve these equations using MATLAB. Specifically I am trying to get an output of the form: `X/V = [] / []`
Looking on the mathworks forum and documentation I thought that using `syms` and `solve` would be a good approach.
This is my code:
clc,clear all;
% I*R + L*s*I + a*s*Y - V = 0
% B*I + m*s^2*Y - k2*X + k2*Y - b2*s*X + b2*s*Y = 0
% -B*I + M*s^2*X + (b1 + b2)*s*X - b2*s*Y + (k1+k2)*X - k2*Y = 0
syms s Y I R L V B m k1 k2 b1 b2 X a M
sol = solve([I*R + L*s*I + a*s*Y - V == 0, B*I + m*s^2*Y - k2*X + k2*Y - b2*s*X + b2*s*Y == 0, -B*I + M*s^2*X + (b1 + b2)*s*X - b2*s*Y + (k1+k2)*X - k2*Y == 0], [X,V]);
sol.X/V
sol.X
sol.V
As can be seen, when I try to solve for `[X,V]` as required, my command window shows:
ans = *Empty sym: 0-by-1*
This could be because: "the set of equations you are trying to solve does not have a valid symbolic solution" ( Link )
I have also been looking through the official documentation , but I am still getting the same output. When I add `Y` as a symbolic parameter along with `X` and `V` I get the following output:
sol2.X/V
(B*I*m*s^2)/(V*(k1*k2 + b1*m*s^3 + b2*m*s^3 + k1*m*s^2 + k2*m*s^2 + b1*k2*s + b2*k1*s + M*b2*s^3 + M*k2*s^2 + M*m*s^4 + b1*b2*s^2))
sol2.X
(B*I*m*s^2)/(k1*k2 + b1*m*s^3 + b2*m*s^3 + k1*m*s^2 + k2*m*s^2 + b1*k2*s + b2*k1*s + M*b2*s^3 + M*k2*s^2 + M*m*s^4 + b1*b2*s^2)
How can I solve for X and V, and more specifically get an answer in the form of: X/V = [] / [] ?
Any tips or suggestions would be appreciated!

채택된 답변

Walter Roberson
Walter Roberson 2018년 10월 27일
You are trying to solve three equations for two variables. That is overdetermined and will not generally have a solution.
Question: were you perhaps looking for sol.X/sol.V?
  댓글 수: 2
Ryan Rizzo
Ryan Rizzo 2018년 10월 27일
편집: Ryan Rizzo 2018년 10월 27일
Ah, what a silly mistake. Yes, that is what I am looking for.
Would this be a better implementation?
sol2 = solve([I*R + L*s*I + a*s*Y - V == 0, -B*I == m*s^2*Y - k2*X + k2*Y - b2*s*X + b2*s*Y, B*I == M*s^2*X + (b1 + b2)*s*X - b2*s*Y + (k1+k2)*X - k2*Y], [X,V,Y])
sol2.X/sol2.V
Walter Roberson
Walter Roberson 2018년 10월 27일
That looks plausible.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Computations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by