textscan - line by line multiple outputs
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (1)
per isakson
am 11 Mär. 2014
Bearbeitet: per isakson
am 11 Mär. 2014
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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Text Data Preparation finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!