problem in finding the mode for the following matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
mahesh bvm
am 9 Jan. 2014
Kommentiert: mahesh bvm
am 9 Jan. 2014
Consider a matrix JJ
JJ
JJ =
2.3159 1.9527 1.8476 1.9527
2.7977 0.8633 0.0298 0.8633
0.0438 1.0645 0.0438 0.0880
0.7228 2.0592 0.7228 0.2329
0.2228 1.4990 0.2228 0.0414
Now,I need find the mode in each row. I tried this already by giving the command mode(JJ,2). The answer I got is this.
mode(JJ,2)
ans =
1.9527
0.0298
0.0438
0.2329
0.0414
As it can be seen the answer is wrong with respect to 2nd, 4th and 5th rows. The common elements or mode of 2nd, 4th and 5th is 0.8633, 0.7228 and 0.2228 respectively. Why the mode command is showing a wrong answer??
Any help is highly appreciated.
0 Kommentare
Akzeptierte Antwort
Patrik Ek
am 9 Jan. 2014
It works for me with the given atrix. Are you sure this is the exact values of JJ? Otherwise you need to truncate it to a tolerance. This is done as
newMtx = round(1/tol*mtx)*tol;
truncation to 4 decimals would then be have tol = 1/10^4
newMtx = round((10^4)*mtx)/10^4;
Thank you for accepting the answer :)
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!