0

In my numerical analysis class we sometimes need to do calculations with t-digit rounding arithmetics, i.e. every calculation (every calculation, not every variable assignment) is rounded to t meaning-full digits. I'm using matlab for my calculations, and I need a way to limit matlab to do all of its calculations in t-digit rounding arithmetics.

If no such way exist, I would want to find a way to round specific number to t meaning-full digits.

Thanks!

p.s. I tried using digits(t) but it seems to effect only the way matlab display the numbers (I may be using it wrong).

  • In my assignment I need to solve a linear system Ax=b using elimination, with 3-digit round arithmetic. I don't think this is too absurd, this what happened in "real life" but with 32 or 64 digits (if I'm not wrong). This meant to emphasise this phenomenon – Barak Ohana Oct 28 '17 at 15:35
  • In addition to `vpa` (as mentioned by @user2305193) you can also use the [Fixed Point Designer](https://www.mathworks.com/help/fixedpoint/index.html). Neither are in base MATLAB - i.e. they are in add-on Toolboxes. – Phil Goddard Oct 28 '17 at 16:43

1 Answers1

0

You can use:

 system_dependent('setprecision',24); %accepts values 24, 53 or 64

as described in this and this resource.

user2305193
  • 2,079
  • 18
  • 39