Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Prellocate memory to unknown size array ?

1 Ansicht (letzte 30 Tage)
dipak sanap
dipak sanap am 24 Nov. 2015
Geschlossen: Walter Roberson am 24 Nov. 2015
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)

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by