how to read .sts file in matlab?
18 次查看(过去 30 天)
显示 更早的评论
hi..i have .sts file(45000). i need to read this files in a loop and append them into an excel file. in each .sts file,it contains data like below,
SAMPLE_20130606_0006 0 +6.470299E+0 +4.009076E+0 +1.699308E+1 +1.095633E+0
SAMPLE_20130606_0016 0 +6.938715E+0 +2.954977E+0 +1.125970E+1 +1.396087E+0
SAMPLE_20130606_0026 0 +8.297382E+0 +4.155266E+0 +2.333013E+1 +1.611527E+0
SAMPLE_20130606_0036 0 +8.837934E+0 +5.234266E+0 +1.352240E+1 +1.407429E+0
SAMPLE_20130606_0046 0 +8.098710E+0 +3.642447E+0 +1.205176E+1 +1.683126E+0
how to read this file in a loop and save in excel format?
0 个评论
采纳的回答
Walter Roberson
2013-9-5
xlswrite() for the file writing.
When you read the data, do you want all fields (including the text line), or do you only want the numbers? Perhaps only the last 4 numbers?
If you want everything, just broken out into fields, the consider using fileread() to read the file, and regexp() with 'split' option to break it into fields.
3 个评论
Walter Roberson
2013-9-10
Use fullfile() to construct the input and output file names. xlswrite() will be perfectly happy to be given a file name in a different directory.
Walter Roberson
2013-9-10
indir = 'INPUT';
outdir = 'OUTPUT';
finfo = dir(fullfile(indir, '*.sts'));
massoutput = {};
for K = 1 : length(finfo);
thisfilename = fullfile(indir, finfo(K).name);
sts = fileread(thisfilename);
t = regexp(regexp(regexprep(sts, ' *\n *$', ''), ' *\n', 'split'), '\s+', 'split');
massoutput{K} = vertcat(t{:});
end
massoutput = vertcat(massoutput{:});
thisfilename = fullfile(outdir, 'allsts.xls');
xlswrite(thisfilename, massoutput);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!