適切に構成された入力テキスト ファイルがあります。
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、フランチェスコ