How to solve parametric simultaneous equations in MATLAB?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ryan Rizzo
am 27 Okt. 2018
Kommentiert: Walter Roberson
am 27 Okt. 2018
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!
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 27 Okt. 2018
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!