MATLAB: An efficient way to import data containing letters and numbers

data importletters

Hello,
I am trying to generate some netcdf files with data sets containing numerical values along with data flags represented by numbers. Here is what some data looks like:
01108431895 487X 445X 599X 662X 726X
01108431896 484X 535X 568X 702E 778X
01108431897 465X 563X 666X 657X 701X
01108431898 531E 514E 634E 614E 752E
Is there any way to import this data and use it to create 3-d arrays so it looks exactly the way it does above, with the letter flags?
Thanks, Dan

Best Answer

fid = fopen('YourFileName', 'rt');
indata = textscan(fid, '%s%s%s%s%s%s');
fclose(fid);
Now indata{1} will be a cell array of strings which is the first column, indata{2} will be a cell array of strings which is the second column, and so on.
If everything is in a netcdf file instead of a text file, the import methods would not be the same. I am not familiar enough with netcdf to advise.