need help with textscan order

3 visualizzazioni (ultimi 30 giorni)
Mohamed Ibrahim
Mohamed Ibrahim il 15 Feb 2020
Risposto: Walter Roberson il 16 Feb 2020
i want to get some data from txt file so i used textscan order
saveFlnmCl = 'Save_Airfoil.txt';
fidAirfoil = fopen(saveFlnmCl);
dataBuffer = textscan(fidAirfoil,'%f%f%f%f%f%f%f','Delimiter',' ','MultipleDelimsAsOne',true,'CollectOutput',1,'HeaderLines',3);
and here is my text file
XFOIL Version 6.99
Calculated polar for: NACA 2412
1 1 Reynolds number fixed Mach number fixed
xtrf = 1.000 (top) 1.000 (bottom)
Mach = 0.000 Re = 0.010 e 6 Ncrit = 9.000
alpha CL CD CDp CM Top_Xtr Bot_Xtr
------ -------- --------- --------- -------- -------- --------
4.000 0.1967 0.05553 0.03113 -0.0105 1.0000 1.0000
i want to read the values of alpha CL CD CDp CM Top_Xtr Bot_Xtr
so i write
al = dataBuffer{1}(:,1);
CL = dataBuffer{1}(:,2);
CD = dataBuffer{1}(:,3);
CDp = dataBuffer{1}(:,4);
CM = dataBuffer{1}(:,5);
Top_Xtr = dataBuffer{1}(:,6);
Bot_Xtr = dataBuffer{1}(:,7);
but the answer appear as empty array as shown
i think the problem is from this line
dataBuffer = textscan(fidAirfoil,'%f%f%f%f%f%f%f','Delimiter',' ','MultipleDelimsAsOne',true,'CollectOutput',1,'HeaderLines',3);
any suggestions please
the text file is attached
  3 Commenti
Walter Roberson
Walter Roberson il 16 Feb 2020
13 header lines.
Mohamed Ibrahim
Mohamed Ibrahim il 16 Feb 2020
i tried 13 header line but gives me empty array too then i tried 12 header and it gives me the data thank you for your help

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 16 Feb 2020
S = fileread(Save_Airfoil.txt);
S = regexprep(S, '^.*---\s*$', '', 'lineanchors');
dataBuffer = cell2mat(textscan(S, '%f%f%f%f%f%f%f'));

Community Treasure Hunt

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

Start Hunting!

Translated by