それぞれが 6 列の約 1000 個の 150 万行のファイルで構成されるデータ セットがあります。ファイルは、約 50 の気象観測所からのものです。理論的には、すべてのステーションが時刻同期されています。Matlab 内のセル配列に 50 の各ステーションからのデータを保存しました。各ステーションには、ファイルに対応する cell 配列の cell 配列があります。つまり、ステーション 1 はセル配列 #1 にあり、セル配列 #1 にはファイルの数に対応する X 個のセル配列があります。次に、それぞれに実際のデータが含まれます。最初の列が「時間」で、残りの 50 列がステーションである 1 つの場所にすべてのデータを取得したいと思います。6 列のすべてのデータは必要ありません。まだ。私の戦略は、可能なすべての時間の列と、その後にデータが入れられる 50 個の空の列を持つセル配列を作成することです。次に、各ファイルを見て、
変換を行うためのコードを以下に示します。
% One-second time data in datenum format
times = datenum(2011,11,20,0,0,0:TotalSeconds)';
% The number of files associated with each station
AllLengths = cellfun(@length,TotalData);
% Preallocating irradiance cell array
IrradianceData = cell(length(times),length(AllLengths)+1);
% Loop through the times (November 20, 2011, 00:00:00 to present) and find common times from the data
for ii = 1:length(AllLengths)
for jj = 1:AllLengths(ii)
% This finds the indices of the times within the station file
[~,IdxData,Idxtimes] = intersect(TotalData{ii,1}{jj,1}(:,1),times);
% This adds the irradiance values to another cell array
% Can I do this more efficiently?
for kk = 1:length(Idxtimes)
IrradianceData{Idxtimes(kk),ii+1} = TotalData{ii,1}{jj,1}(IdxData(kk),5);
end
end
end
データ ファイルを検索し、関連付けられたデータをベクトル化された方法でセル配列に追加する方法はありますか? 現在の設定方法はかなり遅いです。提案をいただければ幸いです。