필터 지우기
필터 지우기

textscan - line by line multiple outputs

조회 수: 17 (최근 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 CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by