Reading and Processing Complex Data File
5 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Star Strider
on 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 Comments
See Also
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!