An efficient way to import data containing letters and numbers?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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.
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 NetCDF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!