I'm sorry. But you cannot "set" MATAB to store only two significant digits, or any fixed number of significant digits, other than double or single precision.
I suppose you could round each result to two significant digits after EVERY individual computation. I'm not at all sure why you wish to bother doing such a ridiculous thing anyway, as it would yield complete garbage for results almost always.
The easiest way, IF this is not a homework assignment, would be to use my HPF. tool, which CAN be used to specify a number of decimal digits in all computations. You would need to download and install the toolbox from the File Exchange. Then issue this command:
defaultNumberOfDigits 2 0
So now all computations using HPF numbers will be done in only 2 digits of precision.
p = hpf(pi)
p =
3.1e0
p*3
ans =
9.4e0
So you could easily force all computations done using HPF to be in 2 decimal digits of accuracy. Now just define all of your variables as HPF numbers, and execute the Gauss elimination. Again, a complete waste of time unless it is a homework assignment, and you were forced to do it.
If this is for homework, then do the Gaussian elimination by hand, carrying two digits at each step.
Finally, if your question is only how to retain only two significant digits at the VERY end, WHY? Another silly goal. However, you could just use the round function on the final result.
Best Answer