# How to remove the scientific notation such as -1.200340354078778e+11 from a matrix?

17 views (last 30 days)
Sarah A on 21 Oct 2018
Commented: Sarah A on 22 Oct 2018
Hello,
I have a matrix A that have values such as (-1.200340354078778e+11), how to remove this I order to round the values to the nearest 5 decimal? I need this matrix A to multiply it by the double matrix B.
Regards

Walter Roberson on 21 Oct 2018
What output would you want from (-1.200340354078778e+11) ? -120030000000 ? -120034035407.87800 ?
Your invsw entries range in absolute value from 4.75582810386029e9 to 1.86639023098654e12 . Do you want them rounded to 5 decimal points individually, or 5 relative to the 1e12 value? Should 4.75582810386029e9 become 4.7558e9 (5 decimal places for it) or to 0.00476e12 so that the number of trailing 0 align for the values ?
Sarah A on 22 Oct 2018
actually, it seems I did a mistake in getting invsw, thanks for your help.

Star Strider on 21 Oct 2018
format short
q = -1.200340354078778e+11
q =
-1.2003e+11
The internal precision remains unchanged.

Star Strider on 21 Oct 2018
In general, calculating the inverse of a matrix is discouraged, at least in the context of MATLAB.
What do you want to do with your matrix that requires your taking the inverse of it?
Walter Roberson on 22 Oct 2018
rounding the inverse of a matrix is typically bad mathematics. Matrix inverses are rather sensitive.
Your invsw is not the inverse of sw. Your sw only has rank 87 rather than 90.
>> max(max(sw * invsw))
ans =
99117485673797.8
That should be approximately 1 if the two are inverses.
Sarah A on 22 Oct 2018
Yeeeees. you are right! that's why I got these values.

madhan ravi on 21 Oct 2018
Edited: madhan ravi on 21 Oct 2018
round((-1.200340354078778e+11),5)
Or
A=vpa((-1.200340354078778e+11))
round(A)

Sarah A on 21 Oct 2018
thanks for answering but it change the type of matrix A from double to sym, and I want to multiply A by another double matrix which is B.
Walter Roberson on 21 Oct 2018
round() does not change to sym.
madhan ravi on 22 Oct 2018
Exactly , it doesn’t change to sym as sir Walter mentioned. If you think it changes you can check class of the variable by typing whos A in command window