0

When I solved system of three equations I got e.g.:

ans =

(220187671*1019780050779217710933721438668552804739490^(1/2))/130153889126365944306728960 - 2474730277849696199777672339/3425102345430682744913920
 - (220187671*1019780050779217710933721438668552804739490^(1/2))/130153889126365944306728960 - 2474730277849696199777672339/3425102345430682744913920

How can I change this result to result with accuracy of 3 places after dot? for example:

ans = 123.123
1
  • Why do you have an output like that? Are you using symbolic notations ('sym')? Jun 24, 2014 at 12:03

2 Answers 2

1
vpa(variable,3)

This will display 'variable' with 3 decimal digit accuracy.

0

Convert it to a regular double:

format short
D = double(variable)

then use any kind of printing you like, for example, 3 digits:

fprintf('%.3f\n', D)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.