フィルターのクリア

textscan - line by line multiple outputs

13 ビュー (過去 30 日間)
Jay
Jay 2014 年 3 月 11 日
編集済み: per isakson 2014 年 3 月 11 日
I have a text file of the format:
TITLE = "M:/Data2/CTData/fcg1e09/Warwick/Granular/collapse/DVC_Vec_48x48x48_50%ov/ExportDat/D1.dat"
VARIABLES = "x [mm]" "y [mm]" "z [mm]" "u [m/s]" "v [m/s]" "w [m/s]"
ZONE I=83 J=83 K=45
0.891600 147.559402 0.891600 0.000000 0.000000 0.000000
2.674800 147.559402 0.891600 0.000000 0.000000 0.000000
4.458000 147.559402 0.891600 0.000000 0.000000 0.000000 ...
I want to ignore the first 3 lines. I am interested in blocks of 6889 lines where each set of 83 lines needs to write to a row of a matrix (83x83) - a different matrix for each column. I may want to look at a different set of 6889 lines within the text file.
I can't get textscan to work - I assume because it is not designed for multiple outputs. And textread doesn't have fid options and now archaic. So far I have...
%skip 3+6889x lines
for i=1:(3+6889*slice_no),
fgetl(fid);
end
for j=1:83,
for k=1:83;
[X(j,k), Y(j,k), Z(j,k), U(j,k), V(j,k), W(j,k)] = textscan(fid, '%f %f %f %f %f %f');
end
end
But textscan is failing due to the multiple outputs. Any ideas anyone?

回答 (1 件)

per isakson
per isakson 2014 年 3 月 11 日
編集済み: per isakson 2014 年 3 月 11 日
Textscan has one output argument, which capture all output data. Try something like
C = textscan( fid, '%f%f%f%f%f%f', 83 );
in place of the inner loop

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by