reduceRedundancies
Simplify system of first-order differential algebraic equations by eliminating redundant equations and variables
Syntax
Description
[
eliminates redundant equations and variables from the system of first-order
differential algebraic equations (DAEs) newEqs
,newVars
]
= reduceRedundancies(eqs
,vars
)eqs
. The input argument
vars
specifies the state variables of the system.
reduceRedundancies
returns the new DAE system as a column
vector newEqs
and the reduced state variables as a column
vector newVars
. Each element of newEqs
represents an equation with right side equal to zero.
Examples
Reduce DAE System by Removing Redundant Equations
Simplify a system of five differential algebraic equations (DAEs) in four state variables to a system of two equations in two state variables.
Create the following system of five DAEs in four state variables x1(t)
, x2(t)
, x3(t)
, and x4(t)
. The system also contains symbolic parameters a1
, a2
, a3
, a4
, b
, c
, and the function f(t)
that are not state variables.
syms x1(t) x2(t) x3(t) x4(t) a1 a2 a3 a4 b c f(t) eqs = [a1*diff(x1(t),t)+a2*diff(x2(t),t) == b*x4(t), a3*diff(x2(t),t)+a4*diff(x3(t),t) == c*x4(t), x1(t) == 2*x2(t), x4(t) == f(t), f(t) == sin(t)]; vars = [x1(t),x2(t),x3(t),x4(t)];
Use reduceRedundancies
to eliminate redundant equations and corresponding state variables.
[newEqs,newVars] = reduceRedundancies(eqs,vars)
newEqs =
newVars =
Specify Input Order of State Variables
Specify input order of the state variables to choose which variables are being returned when eliminating DAEs.
Create a system of four DAEs in four state variables V_ac(t)
, V1(t)
, V2(t)
, and I(t)
. The system also contains symbolic parameters L
, R
, and V0
.
syms V_ac(t) V1(t) V2(t) I(t) L R V0 eqs = [V_ac(t) == V1(t) + V2(t), V1(t) == I(t)*R, V2(t) == L*diff(I(t),t), V_ac(t) == V0*cos(t)]
eqs =
vars = [V_ac(t),I(t),V1(t),V2(t)]
vars =
Use reduceRedundancies
to eliminate redundant equations and variables. reduceRedundancies
prioritizes to keep the state variables in the vector vars
starting from the first element.
[newEqs,newVars] = reduceRedundancies(eqs,vars)
newEqs =
newVars =
Here, reduceRedundancies
returns a reduced equation in term of the variable I(t)
.
When multiple ways of reducing the DAEs exist, specify a different input order of the state variables to choose which variables are being returned. Specify another vector that contains a different order of the state variables. Eliminate the DAEs again.
vars2 = [V_ac(t),V1(t),V2(t),I(t)]
vars2 =
[newEqs,newVars] = reduceRedundancies(eqs,vars2)
newEqs =
newVars =
Here, reduceRedundancies
returns a reduced equation in term of the state variable V1(t)
.
Obtain Information About Eliminated Equations
Declare three output arguments when calling reduceRedundancies
to simplify a system of equations and return information about the eliminated equations.
Create the following system of five differential algebraic equations (DAEs) in four state variables x1(t)
, x2(t)
, x3(t)
, and x4(t)
. The system also contains symbolic parameters a1
, a2
, a3
, a4
, b
, c
, and the function f(t)
that are not state variables.
syms x1(t) x2(t) x3(t) x4(t) a1 a2 a3 a4 b c f(t) eqs = [a1*diff(x1(t),t)+a2*diff(x2(t),t) == b*x4(t), a3*diff(x2(t),t)+a4*diff(x3(t),t) == c*x4(t), x1(t) == 2*x2(t), x4(t) == f(t), f(t) == sin(t)]; vars = [x1(t),x2(t),x3(t),x4(t)];
Call reduceRedundancies
with three output arguments.
[newEqs,newVars,R] = reduceRedundancies(eqs,vars)
newEqs =
newVars =
R = struct with fields:
solvedEquations: [2x1 sym]
constantVariables: [x4(t) f(t)]
replacedVariables: [x2(t) x1(t)/2]
otherEquations: f(t) - sin(t)
The function reduceRedundancies
returns information about eliminated equations to R
. Here, R
is a structure array with four fields.
The solvedEquations
field contains the equations that are eliminated by reduceRedundancies
. The eliminated equations contain those state variables from vars
that do not appear in newEqs
. The right side of each eliminated equation is equal to zero.
R1 = R.solvedEquations
R1 =
The constantVariables
field contains a matrix with two columns. The first column contains those state variables from vars
that reduceRedundancies
replaced by constant values. The second column contains the corresponding constant values.
R2 = R.constantVariables
R2 =
The replacedVariables
field contains a matrix with two columns. The first column contains those state variables from vars
that reduceRedundancies
replaced by expressions in terms of other variables. The second column contains the corresponding values of the eliminated variables.
R3 = R.replacedVariables
R3 =
The otherEquations
field contains those equations from eqs
that do not contain any of the state variables vars
.
R4 = R.otherEquations
R4 =
Input Arguments
eqs
— System of first-order DAEs
vector of symbolic equations | vector of symbolic expressions
System of first-order DAEs, specified as a vector of symbolic equations or expressions.
The relation operator ==
defines symbolic
equations. If you specify the element of eqs
as a
symbolic expression without a right side, then a symbolic equation with
right side equal to zero is assumed.
vars
— State variables
vector of symbolic functions | vector of symbolic function calls
State variables, specified as a vector of symbolic functions or function
calls, such as x(t)
.
The input order of the state variables determines which reduced variables
are being returned. If multiple ways of reducing the DAEs exist, then
reduceRedundancies
prioritizes to keep the state
variables in vars
starting from the first element.
Example: [x(t),z(t),y(t)]
Output Arguments
newEqs
— System of first-order DAEs
column vector of symbolic expressions
System of first-order DAEs, returned as a column vector of symbolic
expressions. Each element of newEqs
represents an
equation with right side equal to zero.
newVars
— Reduced set of variables
column vector of symbolic function calls
Reduced set of variables, returned as a column vector of symbolic function calls.
R
— Information about eliminated variables
structure array
Information about eliminated variables, returned as a structure array containing four fields. To access this information, use:
R.solvedEquations
to return a symbolic column vector of all equations thatreduceRedundancies
used to replace those state variables that do not appear innewEqs
.R.constantVariables
to return a matrix with the following two columns. The first column contains those original state variables of the vectorvars
that were eliminated and replaced by constant values. The second column contains the corresponding constant values.R.replacedVariables
to return a matrix with the following two columns. The first column contains those original state variables of the vectorvars
that were eliminated and replaced in terms of other variables. The second column contains the corresponding values of the eliminated variables.R.otherEquations
to return a column vector containing all original equationseqs
that do not contain any of the input variablesvars
.
Version History
Introduced in R2014b
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)