Categories

# Complex Conjugate Matlab

Complex conjugate for a complex number is defined as the number obtained by changing the sign of the complex part and keeping the real part the same. The significance of complex conjugate is that it provides us with a complex number of same magnitude‘complex part’ but opposite in direction. For example, if we have ‘a + ib’ as a complex number, then the conjugate of this will be ‘a – ib’. For a matrix, the complex conjugate is obtained by taking the conjugate of each element of the matrix.

In Matlab, we use ‘conj’ function for finding the complex conjugate of complex numbers.

## Syntax:

``C = conj (Z)``

## Description:

• C = conj (Z) is used to get the complex conjugate
• For a matrix, we will get a complex conjugate of every element in the input matrix

## Examples of Complex Conjugate Matlab

Let us now understand the code of conj function in MATLAB using different examples:

## Example 1:

In this example, we will take a complex number with the positive real and imaginary parts. We will follow the following steps:

1. Initialize the input complex number
2. Pass this complex number as an argument to the conj function

## Code:

``````<!-- wp:paragraph -->
<p><code>Z = 5 + 6i</code>[Initializing the input complex number]</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>C = conj(Z)</code>[Passing the input complex number to the ‘conj’ function] [Mathematically, the complex conjugate of 5 + 6i is 5 – 6i. As we can see, only the sign of the imaginary part is changed]</p>
<!-- /wp:paragraph -->``````

## Input:

``````Z = 5 + 6i
C = conj(Z)``````

## Output:

As we can see in the output, the conjugate of 5 + 6i is 5 – 6i, which is the same as expected by us.

## Example 2:

In this example, we will take a complex number with the negative real and imaginary parts. We will follow the following steps:

1. Initialize the input complex number
2. Pass this complex number as an argument to the conj function

## Code:

`Z = -4-2i`[Initializing the input complex number]

`C = conj (Z)`[Passing the input complex number to the ‘conj’ function] [Mathematically, the complex conjugate of -4-2i is -4+2i. As we can see, only the sign of the imaginary part is changed]

## Input:

``````Z = -4-2i
C = conj (Z)``````

## Output:

As we can see in the output, the conjugate of -4 – 2i is -4 + 2i, which is the same as expected by us.

## Example 3:

In this example, we will take a complex number with the positive real and negative imaginary part. We will follow the following steps:

1. Initialize the input complex number
2. Pass this complex number as an argument to the conj function

## Code:

``Z = 6-9i[Initializing the input complex number]``

`C = conj (Z)`[Passing the input complex number to the ‘conj’ function] [Mathematically, the complex conjugate of 6 – 9i is 6 + 9i. As we can see, only the sign of the imaginary part is changed]

## Input:

``````Z = 6-9i
C = conj (Z)``````

## Output:

As we can see in the output, the conjugate of 6 – 9i is 6 + 9i, which is the same as expected by us. Next, let us learn how to use conj function for computing the complex conjugate of a matrix.

## Example 4:

In this example, we will take a 2x2matrix of complex numbers and will find the complex conjugate of the matrix. We will follow the following steps:

1. Initialize the input matrix containing complex elements
2. Pass this complex matrix as an argument to the conj function

## Code:

``Z = [3-2i1+5i; 6+2i3-2i]``

[Initializing the input complex matrix]

`C = conj (Z)`[Passing the input complex matrix to the ‘conj’ function] [Mathematically, the complex conjugate of our input matrix is

``3.00 + 2.00i  1.00 – 5.00i``
``6.00 – 2.00i  3.00 + 2.00i]``

## Input:

``````Z = [3-2i 1+5i; 6+2i 3-2i];
C = conj (Z)``````

## Output:

As we can see in the output, we have obtained the complex conjugate of every element of the matrix.

## Example 5:

In this example, we will take a 3×3 matrix of complex numbers and will find the complex conjugate of the matrix. We will follow the following steps:

1. Initialize the input matrix with complex elements
2. Pass this complex matrix as an argument to the conj function

## Code:

``Z = [4-5i1 -6i  5 + 7i; 3+2i3 +5i  4 - 8i;  3 + 3i  4 - 7i  2 + 8i]``

[Initializing the input complex matrix]

`C = conj (Z)`[Passing the input complex matrix to the ‘conj’ function] [Mathematically, the complex conjugate of our input matrix is

4.00 + 5.00i  1.00 + 6.00i  5.00 – 7.00i

3.00 – 2.00i  3.00 – 5.00i  4.00 + 8.00i

3.00 – 3.00i  4.00 + 7.00i  2.00 – 8.00i]

## Input:

``Z = [4-5i 1-6i  5+7i; 3+2i 3+5i  4-8i;  3+3i  4-7i  2+8i] C = conj(Z)``

## Output:

As we can see in the output, we have obtained the complex conjugate of every element of the matrix.