COUNT FUNCTION MATLAB

  • Follow


Hi all

I have made a loop which outputs a number of numbers.  Ie e=123 or e=125.  I would like to count the frequency of the numbers.  How would I do this.

Thanks
0
Reply Sarah 1/21/2011 8:37:20 AM

Sarah <sroffner@yahoo.co.uk> wrote in message <91969213.4977.1295617070369.JavaMail.root@gallium.mathforum.org>...
> Hi all
> 
> I have made a loop which outputs a number of numbers.  Ie e=123 or e=125.  I would like to count the frequency of the numbers.  How would I do this.
> 
> Thanks

Hi
Convert number to string and get the length of string
e.g
x=1234;
length(num2str(x))

HTH,
Saif
0
Reply user 1/21/2011 1:58:05 PM


Sarah <sroffner@yahoo.co.uk> wrote in message <91969213.4977.1295617070369.JavaMail.root@gallium.mathforum.org>...
> Hi all
> 
> I have made a loop which outputs a number of numbers.  Ie e=123 or e=125.  I would like to count the frequency of the numbers.  How would I do this.
> 
> Thanks

%if you mean by "a number of numbers" an array like
  X = [123 125 11 123 123 12 125]
% you can count them using
  unX = unique(X)
  freq = histc(X,unX)
  disp([unX(:) freq(:)])

hth
Jos
0
Reply Jos 1/21/2011 3:39:05 PM

2 Replies
635 Views

(page loaded in 0.036 seconds)

Similiar Articles:













7/24/2012 4:32:50 AM


Reply: