Reading and Processing Complex Data File

5 visualizaciones (últimos 30 días)
Abhimanyu Jamwal
Abhimanyu Jamwal el 10 de Feb. de 2017
Respondida: Star Strider el 10 de Feb. de 2017
Hey,
I have a Tecplot data file which has point information about different slices of a wing. So the information that I want to extract from the .dat file is in different sections of the file. The structure of the file is something like this:
Line 1-12 - information about the file I don't want ;; Line 12 - 358 - 5 columns of real values i.e. information I want ;; Line 359 - 707 - again numbers I don't want as 2 columns ;; Line 708 - 1054 - 5 columns of real values i.e. information I want ;; ...and the same pattern repeats
I have attached the file for better understanding.
Now since I have many such data files I wanted to write a code where for each file I can just extract the required data in the given line numbers. The format of each data file is the same.
Any help as to how should I go about it would be appreciated.
Thanks

Respuestas (1)

Star Strider
Star Strider el 10 de Feb. de 2017
This seems to work:
fidi = fopen('a10-extended-fine-coupled-wing-x-wall shear stress-cp.txt','rt');
k1 = 1;
while ~feof(fidi)
C = textscan(fidi, '%f%f%f%f%f', 'HeaderLines',11, 'CollectOutput',1);
M = cell2mat(C);
if isempty(M)
break
end
D{k1} = M(~isnan(M(:,3)),:);
fseek(fidi, 0, 0);
k1 = k1 + 1;
end
Note: The collected and edited data are in the ‘D’ cell array.

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by