Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing a text file and sort out the frequecny of each character

Status
Not open for further replies.

ill2000m

Electrical
Oct 7, 2003
7
x =' hskd';
X = sort(x);
[U I J] = unique(X);
N = diff([0 I]);
bar(N)
set(gca,'XtickLabel',U.')


[num2str(N.') U.']

the code above will allow me to sort out the frequency of the charcher
appear in x .

e.g the result is 1h 1s 1k 1d

now i want to import a text file from the directory
'C:\MATLAB6p5\work\test.txt' and the content of test.txt is hskd.

i wish to to use the same program to sort out the frequecny for each
character but when i try to use the fuction importdata it wouldnt work
...... does anyone know how to do it ..

this is the m file i written


x =importdata('C:\MATLAB6p5\work\test.txt')

X = sort(x);
[U I J] = unique(X);
N = diff([0 I]);
bar(N)
set(gca,'XtickLabel',U.')


[num2str(N.') U.']
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor