[A,b] =
equationsToMatrix(eqns)
converts equations eqns to matrix form. eqns must
be a linear system of equations in all variables that symvar finds in
eqns.
Convert a system of linear equations to matrix form. equationsToMatrix automatically detects the variables in the equations by using symvar. The returned coefficient matrix follows the variable order determined by symvar.
Convert a linear system of equations to the matrix form by specifying independent variables. This is useful when the equations are only linear in some variables.
For this system, specify the variables as [s t] because the system is not linear in r.
Consider the following system of linear equations that are functions of time:
Declare the system of equations.
syms x(t)y(t)z(t)u(t)v(t)
eqn1 = 2*x + y + z == 2*u;
eqn2 = -x + y - z == v;
eqn3 = x + 2*y + 3*z == -10;
eqn = [eqn1; eqn2; eqn3]
eqn(t) =
Specify the independent variables , , and in the equations as a symbolic vector vars. Use the equationsToMatrix function to convert the system of equations into the matrix form.
vars = [x(t); y(t); z(t)];
[A,b] = equationsToMatrix(eqn,vars)
A =
b =
Solve the matrix form of the equations using the linsolve function.
X = linsolve(A,b)
X =
Evaluate the solution for the functions and . Plot the solution.
Linear equations, specified as a vector of symbolic equations or expressions.
Symbolic equations are defined by using the == operator, such as
x + y == 1. For symbolic expressions,
equationsToMatrix assumes that the right side is 0.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.