need help with textscan order
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
Risposte (1)
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'));
0 Commenti
Vedere anche
Categorie
Scopri di più su Text Files 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!