Borrar filtros
Borrar filtros

How to solve parametric simultaneous equations in MATLAB?

3 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Oct. de 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 comentarios
Ryan Rizzo
Ryan Rizzo el 27 de Oct. de 2018
Editada: Ryan Rizzo el 27 de Oct. de 2018
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 el 27 de Oct. de 2018
That looks plausible.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Computations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by