By default, MATLAB displays numbers with four decimal place values. This is known as short format.
However, if you want more precision, you need to use the format command.
The format long command displays 16 digits after decimal.
For example:
format long
x = 7 + 10/3 + 5 ^ 1.2
MATLAB will execute the above statement and return the following result:
x =
17.231981640639408
Another example,
format short
x = 7 + 10/3 + 5 ^ 1.2
MATLAB will execute the above statement and return the following result:
x =
17.2320
The format bank command rounds numbers to two decimal places.
For example,
format rat
The format rat command gives the closest rational expression resulting from a calculation.
For example,
3.141592653589793e+00x =
MATLAB will execute the above statement and return the following result:x = piformat long e
The format long e command allows displaying in exponential form with four decimal places plus the exponent.
For example,2.2922e+01ans =
MATLAB will execute the above statement and return the following result:4.678 * 4.9format short e
For example,
The format short e command allows displaying in exponential form with four decimal places plus the exponent.MATLAB displays large numbers using exponential notation.1064.70weekly_wage =
MATLAB will execute the above statement and return the following result:weekly_wage = daily_wage * 6daily_wage = 177.45;
format bank
2063/90ans =
MATLAB will execute the above statement and return the following result:4.678 * 4.9
Click Here To Watch Video..!