COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### COUNT FUNCTION MATLAB

• Email
• 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

See related articles to this posting

```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

```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