Q:

Experiment, in the Command Window, with using the fprintf function for real numbers. Make a note of what happens for each. Use fprintf to print the real number 12345.6789

0

Experiment, in the Command Window, with using the fprintf

function for real numbers. Make a note of what happens for each. Use

fprintf to print the real number 12345.6789.

realnum = 12345.6789;

  1. without specifying any field width
  2. in a field width of 10 with 4 decimal places
  3. in a field width of 10 with 2 decimal places
  4. in a field width of 6 with 4 decimal places
  5. in a field width of 2 with 4 decimal places

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answers:

1/

>> fprintf('The number is %f\n', realnum)

The number is 12345.678900

2/

>> fprintf('The number is %10.4f\n', realnum)

The number is 12345.6789

3/

>> fprintf('The number is %10.4f\n', realnum)

The number is 12345.6789

4/

>> fprintf('The number is %6.4f\n', realnum)

The number is 12345.6789

5/

>> fprintf('The number is %2.4f\n', realnum)

The number is 12345.6789

 

 

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now