Reading and Processing Complex Data File
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
Star Strider
il 10 Feb 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.
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Import and Export in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!