次の機能を実行する for ループがあります。
M x 8 行列を取得し、次のようにします。
- それをサイズ 512 要素のブロックに分割します (つまり、行列の X x 8 == 512 であり、要素数は 128,256,512,1024,2048 になる可能性があります)。
- ブロックを 1 × 512 (要素数) の行列に変形します。
行列の最後の1/4を取り、前に置きます。Data = [Data(1,385:512),Data(1,1:384)];
以下は私のコードです:
for i = 1 : NumOfBlock
if i == 1
Header = tempHeader(1:RowNeeded,:);
Header = reshape(Header,1,BlockSize); %BS
Header = [Header(1,385:512),Header(1,1:384)]; %CP
Data = tempData(1:RowNeeded,:);
Data = reshape(Data,1,BlockSize); %BS
Data = [Data(1,385:512),Data(1,1:384)]; %CP
start = RowNeeded + 1;
end1 = RowNeeded * 2;
else
temp = tempData(start:end1,:);
temp = reshape(temp,1,BlockSize); %BS
temp = [temp(1,385:512),temp(1,1:384)]; %CP
Data = [Data, temp];
end
if i <= 127 & i > 1
temp = tempHeader(start:end1,:);
temp = reshape(temp,1,BlockSize); %BS
temp = [temp(1,385:512),temp(1,1:384)]; %CP
Header = [Header, temp];
end
start = end1 + 1;
end1=end1 + RowNeeded;
end
500 万の要素でこのループを実行すると、1 時間以上かかります。できるだけ速くする必要があります(秒単位)。このループはベクトル化できますか?
