我有一个结构良好的输入文本文件:
START_PARAMETERS
C:\Users\admin\Desktop\Bladed_wind_generator\_wind
C:\Users\admin\Desktop\Bladed_wind_generator\reference_v_4_2.$PJ
END_PARAMETERS
---------------------------------------------------------------------------
START_DLC1-2
4 6 8 10 12 14 16 18 20 22 24 26 28 29
6
8192
600
END_DLC1-2
---------------------------------------------------------------------------
START_DLC6-1
44.8
30
8192
600
END_DLC6-1
---------------------------------------------------------------------------
START_DLC6-4
3 31 33 35
6
8192
600
END_DLC6-4
---------------------------------------------------------------------------
START_DLC7-2
2 4 6 8 10 12 14 16 18 20 22 24
6
8192
600
END_DLC7-2
---------------------------------------------------------------------------
目前我是这样读的:
clc,clear all,close all
f = fopen('inp.txt','rt'); % Read Input File
C = textscan(f, '%s', 'Delimiter', '\r\n');
C = C{1}; % Store Input File in a Cell
fclose(f);
然后,通过正则表达式,我读取了 (START_DLC/END_DLC) 块的每次出现:
startIndx = regexp(C,'START_DLC','match');
endIndx = regexp(C,'END_DLC','match');
目的是将每个 START_DLC/END_DLC 块之间的文本内容存储在结构化单元格中(应该称为 store_DLCs)。结果必须是(例如 DLC1-2):
DLC1-2
4 6 8 10 12 14 16 18 20 22 24 26 28 29
6
8192
600
以此类推,直到 DLC7-2。
你介意给我一些提示吗?
我提前感谢大家。
BR,弗朗西斯科