For the rest os the values, the first 12 decimal numbers are equal, the problem is with the 13 and 14 decimals number...maybe some limitation on the excel side?
I get a different mean in matlab that i got from Excel for the same input
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
So my input table is A.mat, since I have NaN values in there I use nanmean for the calculation. using nanmean from Matlab or average with excel I get the same value (as expected) 52.8926514537196000. now I wanna do the calculation for example of A(3,1) - nanmean(A). (because the first are equal, as I made a logical value in excel)
From Matlab I get 7.22209082533311000, from excel I get 7.22209082533308000, why the two values are different? I made a verification in excel, the two means are the same, the only "problem" may be related to the operation "-", any ideas why
Thanks for your time.
load('A.mat');
media_mc = mean(A);
media_nan_mc = nanmean(A);
calculation = A(3,1) - nanmean(A);
Respuestas (1)
Guillaume
el 1 de Mzo. de 2018
If matlab and excel wrote a 1000 digits after the decimal point and the 999th digit differed would you still worry about the difference?
Looking at difference in the 12th digit of precision is pointless. A slightly difference in algorithm can easily result in that difference. For all intent and purpose, the two numbers are exactly the same.
You probably need to learn more about floating point numbers and their accuracy. Your next question might be why is 0.1 + 0.1 + 0.1 not equal to 0.3?
>> isequal(0.1+0.1+0.1, 0.3)
ans =
logical
0
Note that both excel and matlab are lying to you anyway. For example, they cannot store the number 0.1 exactly, they're storing its nearest representation in binary that they round to 0.1 when displaying the number.
Ver también
Categorías
Más información sobre Data Import from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!