MATLAB mode function

  • MATLAB
  • Thread starter hoheiho
  • Start date
  • #1
47
0

Main Question or Discussion Point

Hi, im a bit confusing on the mode function in MATLAB. I have look throught some books and say we can use mode function to find "the most show up value" and "show up how many times". For example :
r =

2 2 3
3 3 3
4 2 1

the most show up value is 3 and it shows up 4 times. The mode function will be mode(3,4)??How can i use it in .m file? Like i have "r" and now i wanna use mode function to find the 3 and 4??Is there any example for that? coz lots of books just discrible what is mode function and didnt say how to use. Could anyone give me a hand on this?

Thanks
Ivan
 

Answers and Replies

  • #2
MATLABdude
Science Advisor
1,655
4
In addition to what I said in your other thread, the online documentation has a great number of examples. For instance, for the mode command:
http://www.mathworks.com/help/techdoc/ref/mode.html

As per the link above, when you have a matrix, the mode command finds the most frequently-occurring (not 'showed-up') values in every column. If you wanted to find the most frequently-occurring value in the entire matrix, you need to turn the matrix into a single row or column vector using reshape:
http://www.mathworks.com/help/techdoc/ref/reshape.html
 

Related Threads for: MATLAB mode function

Replies
0
Views
1K
  • Last Post
Replies
3
Views
4K
  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
5
Views
11K
Replies
7
Views
15K
Replies
0
Views
2K
Replies
4
Views
1K
  • Last Post
Replies
1
Views
1K
Top