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
Polar Form: Any complex number z = a + bi can be thought of as a point (a,b) or vector in the complex plane in which the horizontal axis is the real part of z, and the vertica

Differentiation: The derivative of a function y = f(x) can be written as follows or f  '(x) and is defined as the rate of change of the dependent variable y with respe

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

Example of Recursive functions: This definition is recursive as a factorial is defined in terms of the other factorial. There are two parts to any recursive definition: the co

Print an imaginary number: To print an imaginary number, the function disp will show both parts automatically: >> disp(z1)    4.0000 + 2.0000i The function fprint

Writing variables to a File: The save command is used to write variables to a file, or to append the variables to a MAT-file. By the default, save function writes to a MAT-fil

Referring to and Modifying the Matrix Elements: To refer to matrix elements, the row and then the column indices are given in parentheses (always the row index initially and t

Script a MATLAB program which meets the following speci cations: The program expects an input of a two-variable real-valued continuous function f : R^2--> R The program is to cal

User input in the while loop: Here is an illustration of running this script: >> readonenum Enter a positive number: -5 Invalid! Enter a positive number: -2.2

bar and barh functions: For a matrix, the bar and barh functions will group altogether the values in each and every row. The illustration is as shown: rm = randint(2,4,[1