All Possible combinations of rows
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to make a vector matrix where each column represents all possible points in an image. Here is what I want to do
s1=2160;
s2=3600;
count=1;
for i=1:s1
for j=1:s2
vector(:,count)=[j;i;1];
count=count+1;
end
end
but in a much faster way using vectorization. How do I do that ? This simple code takes about 40 seconds to run on my PC.
0 Kommentare
Antworten (1)
Azzi Abdelmalek
am 18 Mär. 2016
Bearbeitet: Azzi Abdelmalek
am 18 Mär. 2016
[ii,jj]=meshgrid((1:s1),(1:s2));
v=[ jj(:) ii(:) ones(s1*s2,1)]';
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!