How to plot from txt file using textscan?

XFOIL Version 6.99
Calculated polar for: NACA 2408
1 1 Reynolds number fixed Mach number fixed
xtrf = 1.000 (top) 1.000 (bottom)
Mach = 0.000 Re = 9.000 e 6 Ncrit = 9.000
alpha CL CD CDp CM Top_Xtr Bot_Xtr
------ -------- --------- --------- -------- -------- --------
0.000 0.2388 0.00480 0.00041 -0.0529 0.4528 0.2191
1.000 0.3512 0.00477 0.00048 -0.0532 0.3796 0.3528
2.000 0.4613 0.00494 0.00072 -0.0533 0.2523 0.5660
4.000 0.6729 0.00562 0.00159 -0.0513 0.0456 0.9816
5.000 0.7881 0.00625 0.00207 -0.0524 0.0199 1.0000
6.000 0.8975 0.00690 0.00262 -0.0521 0.0110 1.0000
7.000 1.0060 0.00760 0.00326 -0.0518 0.0076 1.0000
8.000 1.1129 0.00842 0.00404 -0.0513 0.0053 1.0000
9.000 1.2181 0.00931 0.00492 -0.0506 0.0044 1.0000
11.000 1.4217 0.01152 0.00716 -0.0484 0.0032 1.0000
12.000 1.5182 0.01294 0.00863 -0.0467 0.0027 1.0000
13.000 1.6086 0.01477 0.01056 -0.0441 0.0022 1.0000

4 个评论

Which information do you need to extract from the table?
What data do you get out of the file if you use
filename = 'NameOfFileGoesHere.txt';
opt = detectImportOptions(filename);
data = readtable(filename, opt);
I need to plot alpha vs CL, CL vs CD etc.
I am getting this following
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10 Var11
____ ______ _______ _______ _______ ______ ______ ____ _______ _____ _____
NaN NaN 1 NaN 1 NaN NaN NaN '' '' NaN
NaN NaN 0 NaN NaN 9 NaN 6 'Ncrit' '=' 9
NaN NaN NaN NaN NaN NaN NaN NaN '' '' NaN
NaN NaN NaN NaN NaN NaN NaN NaN '' '' NaN
NaN NaN NaN NaN NaN NaN NaN NaN '' '' NaN
0 0.2388 0.0048 0.00041 -0.0529 0.4528 0.2191 NaN '' '' NaN
1 0.3512 0.00477 0.00048 -0.0532 0.3796 0.3528 NaN '' '' NaN
2 0.4613 0.00494 0.00072 -0.0533 0.2523 0.566 NaN '' '' NaN
4 0.6729 0.00562 0.00159 -0.0513 0.0456 0.9816 NaN '' '' NaN
5 0.7881 0.00625 0.00207 -0.0524 0.0199 1 NaN '' '' NaN
6 0.8975 0.0069 0.00262 -0.0521 0.011 1 NaN '' '' NaN
7 1.006 0.0076 0.00326 -0.0518 0.0076 1 NaN '' '' NaN
8 1.1129 0.00842 0.00404 -0.0513 0.0053 1 NaN '' '' NaN
9 1.2181 0.00931 0.00492 -0.0506 0.0044 1 NaN '' '' NaN
11 1.4217 0.01152 0.00716 -0.0484 0.0032 1 NaN '' '' NaN
12 1.5182 0.01294 0.00863 -0.0467 0.0027 1 NaN '' '' NaN
13 1.6086 0.01477 0.01056 -0.0441 0.0022 1 NaN '' '' NaN
You could probably add a 'HeaderLines' option to the detectImportOptions. I think it might be 'HeaderLines', 9
Thanks! it works
filename = 'Save_Polar.txt';
opt = detectImportOptions(filename);
data = readtable(filename, opt);
D=data(6:end,1:5);
Alpha =D{:,1};
CL =D{:,2};
CD =D{:,3};
CDp =D{:,4};
CM =D{:,5};

请先登录,再进行评论。

回答(1 个)

Paul
Paul 2020-10-11
I’ve been having a lot of success lately in these types of problems by using extractFileText to read it all into a string, and then using a few manipulations to get to the data. Works well if you have a well-defined file format.

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

版本

R2018a

标签

提问:

MG
2020-10-11

评论:

MG
2020-10-11

Community Treasure Hunt

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

Start Hunting!

Translated by