How to track numbers in the MATLAB excel sheet?

2 views (last 30 days)
Tony
Tony on 2 May 2014
Edited: Justin on 2 May 2014
I asked a function to run which produces a lot of numbers which I then can see in the MATLAB excel sheet. Is there a way to find out how many times a certain number showed up in the excel sheet or have it highlight every one of a certain number?
thanks.

Answers (1)

Justin
Justin on 2 May 2014
Edited: Justin on 2 May 2014
I believe the correct name for what you are referring to as the Matlab excel sheet is called the Variable Editor.
A simple answer to your question would be to take a sum of all values in the array equal to the number you are interested in.
For example:
% define your array
x = [1 2 3 4 3 4 3 2 1 3];
% x == 3 will make a logical array where there will be a one for every value that is equal to 3
isValue = x == 3;
% sum will add up all the values in the logical array giving you a count of how many number threes there are
count = sum(isValue(:))
I would definitely recommend going to this site http://www.mathworks.com/academia/student_center/tutorials/launchpad.html and doing the Getting Started with MATLAB tutorial. Also take a look at http://www.mathworks.com/products/matlab/examples.html.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!