ill2000m
Electrical
- Oct 7, 2003
- 7
I have written a M file which allows me to sort the frequencies with which each symbol appears in x,
from most frequent to least frequent... but i would like to sort frequecy of appearence of the english letter (a-z)inside x ...
e.g.
x =[A,A,B,C,]
so the result i want to get on the screen is 2A, 1B and 1C
does anyone know how to do it ..
%x is a data vector with nonnegative integer components
%F=frequency(x) is the vector whose components are the
%frequencies with which each symbol in appear in x
%from most frequent to least frequent
%
function F = frequency(x)
x =[1,2,3,3,4,4,4,5,5,5]
k=max(x)+1;
for i=1:k;
j=find(x==i-1);
u(i)=length(j);
end
r=find(u>0);
v=u(r);
v=sort(v);
m=length(v);
for i=1:m;
F(i)=v(m-i+1);
hist(x);
title('Frequency of each symbol appear on a text')
xlabel('s')
ylabel('a')
end
from most frequent to least frequent... but i would like to sort frequecy of appearence of the english letter (a-z)inside x ...
e.g.
x =[A,A,B,C,]
so the result i want to get on the screen is 2A, 1B and 1C
does anyone know how to do it ..
%x is a data vector with nonnegative integer components
%F=frequency(x) is the vector whose components are the
%frequencies with which each symbol in appear in x
%from most frequent to least frequent
%
function F = frequency(x)
x =[1,2,3,3,4,4,4,5,5,5]
k=max(x)+1;
for i=1:k;
j=find(x==i-1);
u(i)=length(j);
end
r=find(u>0);
v=u(r);
v=sort(v);
m=length(v);
for i=1:m;
F(i)=v(m-i+1);
hist(x);
title('Frequency of each symbol appear on a text')
xlabel('s')
ylabel('a')
end