MATLAB Numbers

After reading the MATLAB Numbers topic, you will understand numbers and its classification as float, integer, and complex in MATLAB.

In MATLAB numbers are classified as

  • Integer
  • Float
  • Complex

Integer

It is any number having the group of digits either from 0 to 9. The statement in MATLAB is given by

x=10;

fprintf('%d\n',x)

Output

10

Explanation:

  • x is variable.
  • 10 is the integer value assigned to variable x.

Float

It is any number containing a fractional part. The statement in MATLAB is given by

x=120.25;

fprintf('%f\n',x)

Output

120.250000

Explanation:

  • x is variable.
  • 120.25 is the float value assign to variable x.

Complex

It is any number having the imaginary part. The imaginary part is represented by letter j in MATLAB. The statement in MATLAB is given by

x=120+2*j;

fprintf('real part is %d\n',real(x)) 

fprintf('imaginary part is %d\n',imag(x))

Output

real part is 120
imaginary part is 2

Explanation:

  • x is variable.
  • 120+2j is the complex value assign to variable x.

Published by

Electrical Workbook

We provide tutoring in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *