从一个文本文件获取矩阵

时间:2019-09-25 12:32:40

标签: matlab

我需要从附加文本中获取矩阵。 此文件:

stk.v.11.0

WrittenBy    STK_v11.2.0

BEGIN Attitude

NumberOfAttitudePoints      1441

BlockingFactor          20

InterpolationOrder      1

CentralBody         Earth

ScenarioEpoch           1 Sep 2019 07:30:00.000000

Epoch in JDate format:  2458727.81250000000000
Epoch in YYDDD format:    19244.31250000000000


Time of first point: 1 Sep 2019 07:30:00.000000000 UTCG =         2458727.81250000000000 JDate = 19244.31250000000000 YYDDD

CoordinateAxes      Fixed

AttitudeTimeQuaternions
0.00000000000000e+00 -6.31921733422396e-01 -3.17293118154861e-01 -3.46458799928973e-01 6.16414065342263e-01
6.00000000000000e+01 -6.43812442721383e-01 -3.36172942616126e-01 -3.26612615262581e-01 6.04828480481266e-01
1.20000000000000e+02 -6.55079207620880e-01 -3.54631351046725e-01 -3.06354155948717e-01 5.92667670562959e-01
1.80000000000000e+02 -6.65707851270427e-01 -3.72650894083426e-01 -2.85703135087044e-01 5.79946623834615e-01

我需要将这4行矩阵分开并将其分配到一个矩阵变量中...

事实上,我的矩阵要比那大(近1400行),我必须从文本文件中提取并将其存储在矩阵的一个变量中...

1 个答案:

答案 0 :(得分:2)

使用readmatrix并指定要跳过以获取矩阵数据的行数。如果像您的示例中那样将数字固定为25,则:

>> a = readmatrix('textfile.txt','NumHeaderLines',25)

a =

         0   -0.6319   -0.3173   -0.3465    0.6164
   60.0000   -0.6438   -0.3362   -0.3266    0.6048
  120.0000   -0.6551   -0.3546   -0.3064    0.5927
  180.0000   -0.6657   -0.3727   -0.2857    0.5799