# rhs

Right side (RHS) of equation

## Description

example

rhsEqn = rhs(eqn) returns the right side of the symbolic equation eqn. The value of eqn also can be a symbolic condition, such as x > 0. If eqn is an array, then rhs returns an array of the right sides of the equations in eqn.

Conditions that use the > or >= operator are internally rewritten using the < or <= operator. Therefore, rhs returns the original left side. For example, rhs(x > 0) returns x.

## Examples

collapse all

Find the right side of the equation $2\mathit{y}={\mathit{x}}^{2}$ by using rhs.

First, declare the equation.

syms x y
eqn = 2*y == x^2
eqn = $2 y={x}^{2}$

Find the right side of eqn by using rhs.

rhsEqn = rhs(eqn)
rhsEqn = ${x}^{2}$

Find the right side of the condition $\mathit{x}<\mathit{y}+1$ by using rhs.

First, declare the condition.

syms x y
cond = x < y + 1
cond = $x

Find the right side of cond by using rhs.

rhsCond = rhs(cond)
rhsCond = $y+1$

For an array that contains equations and conditions, rhs returns an array of the right sides of those equations or conditions. The output array is the same size as the input array.

Find the right side of the equations and conditions in the vector V.

syms x y
V = [y^2 == x^2, x ~= 0, x*y >= 1]
V = $\left(\begin{array}{ccc}{y}^{2}={x}^{2}& x\ne 0& 1\le x y\end{array}\right)$
rhsV = rhs(V)
rhsV = $\left(\begin{array}{ccc}{x}^{2}& 0& x y\end{array}\right)$

Because any condition using the >= operator is internally rewritten using the <= operator, the sides of the last condition in V are exchanged.

Find the right side of a symbolic equation that involves symbolic matrix variables.

Create the symbolic matrix variables and the symbolic equation.

syms A [2 2] matrix
syms B [2 1] matrix
syms C [1 2] matrix
eqn = B*C == A*A - 2*A + eye(2)
eqn = $B C={\mathrm{I}}_{2}-2 A+{A}^{2}$

Find the right side of the equation by using rhs.

rhsEqn = rhs(eqn)
rhsEqn = ${\mathrm{I}}_{2}-2 A+{A}^{2}$

## Input Arguments

collapse all

Equation or condition, specified as a symbolic equation or condition, or a vector, matrix, or multidimensional array of symbolic equations or conditions.

Data Types: sym | symfun | symmatrix | symfunmatrix

## Version History

Introduced in R2017a

expand all