Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Prellocate memory to unknown size array ?

1 visualización (últimos 30 días)
dipak sanap
dipak sanap el 24 de Nov. de 2015
Cerrada: Walter Roberson el 24 de Nov. de 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)

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by