Why 'for loop' is very slow even working on server
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Shakir Hussain
el 20 de Oct. de 2018
Comentada: Shakir Hussain
el 26 de Oct. de 2018
My 'for loop' looks like
iwant = cell(a,b);
for i =1:17
c = data(:,:,i);
for j = 1:b
idx = inpolygon(X(:),Y(:),S(j).X , S(j).Y);
iwant{i,j} = c(idx);
end
end
Where a =17,c = 420*940, X = 420*940, Y = 420*940 and b = 1*1 which is polygon and its size is (shape_area 56.4087, x= 1*679340, y = 1*679340).
This for loop is taking very long time even days, so how could I execute it in minimum time
Thank you in advance for any kind of help
Respuesta aceptada
Walter Roberson
el 20 de Oct. de 2018
The idx results are the same for all i values for a given j. Loop over j precomputing them and then loop over i pulling out the appropriate entries.
9 comentarios
Walter Roberson
el 23 de Oct. de 2018
I do not know what the individual entries in your cell array are intended to mean.
Más respuestas (1)
Bruno Luong
el 20 de Oct. de 2018
As I mention in another thread you can get on FEX that can be 100 times faster than MATLAB inpolygon, let alone the newy polyshape
7 comentarios
Walter Roberson
el 25 de Oct. de 2018
tt = cell2mat(cellfun(@transpose,test,'uniform',0));
Ver también
Categorías
Más información sobre Contour Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!