lundi 7 septembre 2015

Limiting the number of decimal points taken by matlab for calculation

I was checking the similarity of two random matrices by using two methods ,after addition, sum of one elements of first matrix comes as .7095 and same .7095 for second matrix matrix but when tried to find the difference in sum ,instead of zero it was giving a value very close to zero .Later I checked in work space and find out that first number is actually 0.709485632903040 and the second is 0.709485632903037. It is extremely important for me to have the difference vector to be zero so as I am using that zero in my later stages of my program .If matlab do calculation for a precision in less than 4 or 5 digits I can achieve that. I want to limit the calculation only for 4 or 5 digits,I had used digits(4) but it is not working . I want matlab to do calculation in a precision up to 4 decimal places only(not for display,calculation inside matlab) ,Is there is a way to do that??




Aucun commentaire:

Enregistrer un commentaire