Built-in functions for complex numbers, MATLAB in Mathematics

Built-in functions for Complex numbers: 

We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants). The Complex numbers can be generated by using i or j, for illustration, 5 + 2i or 3 - 4j. The multiplication operator is not needed between the value of the imaginary part and the constant i or j.

The MATLAB also has a function complex which will return a complex number. It receives two numbers, that is the real and imaginary parts in that order, or only one number that would be the real part (therefore the imaginary part would be 0). Here are a few illustrations of generating complex numbers in a MATLAB:

>> z1 = 4 + 2i

z1 =

   4.0000 + 2.0000i

>> z2 = sqrt(-5)

z2 =

   0 + 2.2361i

>> z3 = complex(3,-3)

z3 =

   3.0000 - 3.0000i

>> z4 = 2 + 3j

z4 =

   2.0000 + 3.0000i

>> z5 = (-4) ^ (1/2)

ans =

   0.0000 + 2.0000i

>> myz = input('Enter a complex number: ')

Enter a complex number: 3 + 4i

myz =

   3.0000 + 4.0000i

 

Note that even when j is used in an expression, i is used in the outcome. The MATLAB displays the type of the variables generated here in the Workspace Window (or by using whos) as double (complex). The MATLAB has functions real and imag which return the real and imaginary parts of complex numbers.

>> real(z1)

ans =

   4

>> imag(z3)

ans =

   -3

Posted Date: 10/22/2012 8:53:35 AM | Location : United States







Related Discussions:- Built-in functions for complex numbers, Assignment Help, Ask Question on Built-in functions for complex numbers, Get Answer, Expert's Help, Built-in functions for complex numbers Discussions

Write discussion on Built-in functions for complex numbers
Your posts are moderated
Related Questions
Plot types: Besides plot and bar, there are another plot types like stem plots, histograms, stem plots, area plots and pie charts, and also other functions which customize the

Built in recursive function in MATLAB: We have seen that the built-in function in MATLAB to compute factorials, termed as the factorial and we know how to implement the iterat

Sorting The Sorting is a process of putting a list in order; either in descending (maximum to minimum), or ascending (minimum to maximum) order. For illustration, here is a li

Labels and Prompts: The script loads all the numbers from file into a row vector. It then splits the vector; it stores the initial element that is the experiment number in a v

Illustration of nested function: The output arguments are distinct from variables. The scope of an output argument is merely the nested function; and it cannot be used in the

Program of built-in factorial function: Calling this function yields similar result as the built-in factorial function: >> fact(5) ans =   120 >> factorial(

Illustration of Logical vectors: Calling the function appears to return similar vector as simply vec > 5, and summing the result still works to determine how many elements wer

Illustration of Writing to files: Here is the other illustration in which a matrix is written to a file. At First, an arbitrary 2 × 4 matrix is generated, and then it is writt

Fliplr function: The fliplr function "flips" the matrix from left to right (in another words the left-most column, the first column, become the last column and so on), and the

Creating Customized strings: There are many built-in functions which create customized strings, including blanks, char, and sprintf. We know that the char function can be u