mmorga9
Mechanical
- Jun 17, 2008
- 2
I am fairly new to matlab, and I have written some code to process some image data. My code works fine, except one of the early steps takes an extremely long time to compute. I have a 3 column matrix with approximately 1.4 million rows and I am performing the following code on that matrix:
k=1;
SIZE0=size(Scan);
N=SIZE0(1,1);
for i=1:N
if (Scan(i,1)>=minx) && (Scan(i,1)<=maxx) && (Scan(i,2)>=miny) && (Scan(i,2)<=maxy)
Scanx(k,1)=Scan(i,1);
Scanx(k,2)=Scan(i,2);
Scanx(k,3)=Scan(i,3);
k=k+1;
end
end
I couldn't think of another way to write this for loop, but its too slow. Is there a faster way? Thank you for your help.
-Michael
k=1;
SIZE0=size(Scan);
N=SIZE0(1,1);
for i=1:N
if (Scan(i,1)>=minx) && (Scan(i,1)<=maxx) && (Scan(i,2)>=miny) && (Scan(i,2)<=maxy)
Scanx(k,1)=Scan(i,1);
Scanx(k,2)=Scan(i,2);
Scanx(k,3)=Scan(i,3);
k=k+1;
end
end
I couldn't think of another way to write this for loop, but its too slow. Is there a faster way? Thank you for your help.
-Michael