Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Prellocate memory to unknown size array ?

2 visualizzazioni (ultimi 30 giorni)
dipak sanap
dipak sanap il 24 Nov 2015
Chiuso: Walter Roberson il 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)

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by