Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Prellocate memory to unknown size array ?

1 回表示 (過去 30 日間)
dipak sanap
dipak sanap 2015 年 11 月 24 日
閉鎖済み: Walter Roberson 2015 年 11 月 24 日
numfiles = 3;
A = [];
for i = 1:numfiles
f = fopen(sprintf('F%d', i), 'r');
D = fscanf(f, '%d %d %f',[3, inf]); % Prellocate memory.
D = D';
P(i).element = D;
A = [A; D]; %Prellocate memory
fclose(f);
end
B = zeros(size(A(:,1:2)));
U = setdiff(A(:,1:2),B,'rows');
C = [];
for j = 1:numfiles
Ua(j).ele = setdiff(U(:,1:2), P(j).element(:,1:2),'rows');%Prellocate memory
Ua_z(j).ele = [Ua(j).ele , zeros(size(Ua(j).ele,1),1)]; % Prellocate memory
AU(j).ele = [P(j).element ; Ua_z(j).ele]; % Prellocate memory
AU_sorted(j).ele = sortrows(AU(j).ele); %Prellocate memory
C = [C, AU_sorted(j).ele(:,3)];
end
CU = [U(:,1:2), C]; % Horizontally concatenate U and AU_sorted(j)

回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by