The min and max function return incorrect result!
Mostra commenti meno recenti
Hi, I generate a feature matrix from wavelet dicomposion of an EEG signal, for example with 2x16 double dimensions. But when I want to see max and min for all columns, for some columns, it return 0!!
here is my matrix:
Features = [1227752731.63331, 18338294.3655838, 72667987.4176357, 2710006.87295031, 2623292.81882001, 16791624.0266024, 570620.052920511, 206222.333358212, 1001033.71805223, 16658.1448182973, 43506.1703317381, 143319.583017336, 21259.4058920161, 33646.8754811107, 87870.4592040121, 10139.3064159190
; 373181415.803611, 2184323.98283064, 7124198.60955997, 168359.098887688, 287423.644267531, 1448871.84718216, 42715.7953000498, 30445.2160607579, 100263.257495253, 5559.10902863085, 9485.91790552470, 74748.0071948079, 2814.63617073193, 4522.57176240473, 10081.3836180636, 1715.21296944122];
% As you can see, my 16th column values are:
Features(:,16)
ans =
1.0e+04 *
1.0139
0.1715
% But if I type max(Features), it gets me 0.0000 for column 16th and some other columns as well
max(Features)
ans =
1.0e+09 *
Columns 1 through 10
1.2278 0.0183 0.0727 0.0027 0.0026 0.0168 0.0006 0.0002 0.0010 0.0000
Columns 11 through 16
0.0000 0.0001 0.0000 0.0000 0.0001 0.0000
% But if I type max(Features(:,16)
max(Features(:,16))
ans =
1.0139e+04
So I was wundering what would this happen?!!
Note: I didn't use max or min keywords in any part of my code. I check that with which('max', '-all') command.
Tnx in advance.
Risposta accettata
Più risposte (1)
Rik
il 20 Mag 2020
You didn't notice the exponent:
max(Features)
ans =
1.0e+09 *
If you want to control how your data shows up in the command window you should use fprintf.
6 Commenti
Stephen23
il 20 Mag 2020
"he last column should be this 0.171521296944122"
No, that is incorrect. You didn't notice the exponent 1.0e+04
"but I guess matlab should print result of max(Features)"
It does.
The value 1.0139e4 printed to five significant figures starting with order 9 figure is 0.0000
Walter Roberson
il 20 Mag 2020
Give the command
format long g
and display the data again.
MYB
il 20 Mag 2020
MYB
il 20 Mag 2020
Stephen23
il 20 Mag 2020
"Could you please explain how "The value 1.0139e4 printed to five significant figures starting with order 9 figure is 0.0000" in more detail?!"
Lets use a simple example with 654321 and 9.
Now lets print their values using a common multiplier (the order of the largest value) and three significant figures. First we find the three digits at the required orders:
654321
000009
^^^ % three significant digits
So the output is clearly 6.54e5 and 0.00e5. Then you move the common multiplier and display it at the top:
1e5*
6.54 0.00
Categorie
Scopri di più su EEG/MEG/ECoG in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!