How to solve parametric simultaneous equations in MATLAB?

3 次查看(过去 30 天)
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

请先登录,再进行评论。

更多回答(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