matlab - insert the content of a text file into a variable -



matlab - insert the content of a text file into a variable -

i want load text file whit ascii characters , set content varialbe in matlab, code tried :

f =fopen('tp.txt')

the result 1, increments each time excute code line.

however, when seek :

f =load('tp.txt')

i error :

??? error using ==> load number of columns on line 1 of ascii file d:\cours\tp\tp.txt must same previous lines. error in ==> tpti @ 3 f =load('tp.txt')

my goal count occurance of each charachter calculate propabilites , entropies.

any idea?

try this:

%// import file contents string str = importdata('tp.txt'); %// each line cell str = [str{:}]; %// concat lines single string %// remove spaces. maybe want remove other characters well: punctuation... str = regexprep(str, '\s', ''); %// count frequency of each character: freq = histc(double(str), 0:255); %// convert characters ascii codes , count

matlab

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -