This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

eq

Define symbolic equation

Syntax

A == B
eq(A,B)

Description

example

A == B defines a symbolic equation. Use the equation as input to functions such as solve, assume, fcontour, and subs.

eq(A,B) is equivalent to A == B.

Examples

collapse all

Solve this trigonometric equation. Define the equation by using the == operator.

syms x
eqn = sin(x) == cos(x);
solve(eqn,x)
ans =
pi/4

Plot the equation sin(x2)=sin(y2) by using fimplicit. Define the equation by using the == operator.

syms x y
eqn = sin(x^2) == sin(y^2);
fimplicit(eqn)

Test the equality of two symbolic expressions by using isAlways.

syms x
eqn = x+1 == x+1;
isAlways(eqn)
ans =
  logical
   1
eqn = sin(x)/cos(x) == tan(x);
isAlways(eqn)
ans =
  logical
   1

Check the equality of two symbolic matrices by using isAlways.

A = sym(hilb(3));
B = sym([1 1/2 5; 1/2 2 1/4; 1/3 1/8 1/5]);
isAlways(A == B)
ans =
  3×3 logical array
     1     1     0
     1     0     1
     1     0     1

Compare a matrix and a scalar. The == operator expands the scalar into a matrix of the same dimensions as the input matrix.

A = sym(hilb(3));
B = sym(1/2);
isAlways(A == B)
ans =
  3×3 logical array
     0     1     0
     1     0     0
     0     0     0

Input Arguments

collapse all

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

Tips

  • Calling == or eq for nonsymbolic A and B invokes the MATLAB® eq function. This function returns a logical array with elements set to logical 1 (true) where A and B are equal; otherwise, it returns logical 0 (false).

  • If both A and B are arrays, then they must have the same dimensions. A == B returns an array of equations A(i,j,...) == B(i,j,...).

Introduced in R2012a