Problem by importing alpha numeric text files

1 view (last 30 days)
I have an alpha numeric text file. Thus, among many values, I have
also the output 'NA' for non available value of a given row and
column number.
I don't know how to load this type of table. It seems that Matlab
matrices can't include alphanumeric quantities.
I used the command line:
and it always returns the
??? Error using ==> load Unknown text on line number 1 of ASCII file
I wounder if someone knows what I have to change to load the matrix
as original and still be able to perform calculations with it.
I don't want to substitute 'NA' by zero because I don't want that
the value zero be included in further statistical calculations, such
as median, etc...
Thank you,

Accepted Answer

Oleg Komarov
Oleg Komarov on 28 Aug 2011
fid = fopen('c:\myfile.txt');
data = textscan(fid,'format','TreatAsEmpty','NA','EmptyValue',NaN);
Emerson De Souza
Emerson De Souza on 28 Aug 2011
Thank you a lot Oleg!
Problem is fixed by your suggestions.
Wish you a nice day

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by