An efficient way to import data containing letters and numbers?

조회 수: 1 (최근 30일)
Dan
Dan 2012년 1월 20일
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
  댓글 수: 6
Image Analyst
Image Analyst 2012년 1월 20일
Your subject says you're trying to import data, but your body says you're trying to generate a netcdf file. Which is it? Read in or write out?
By the way, there is a netcdf listing in the help you know, with all kinds of things you can do with netcdf files.
Dan
Dan 2012년 1월 20일
Sorry for the unclear wording, I am trying to read in the data from a text file and then create 3-d arrays to use to write netcdf files.
I don't need help creating the netcdf file, just properly importing the data.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 20일
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.
  댓글 수: 1
Dan
Dan 2012년 1월 20일
Thanks Walter, for some reason I couldn't get textscan to work for me before. This is exactly what I needed!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by