FIND function for two different sets

Hello,
I have a point cloud from .las and I opened it in Matlab as .txt. Then I created M array which determines X, Y and Z coordinates. I need to find all X's and all Y's that follows formulas: i > max(X)-(i*r) & i < max(X)-(i-1)*r AND j > min(Y)+(j-1)*r & j < min(Y)+(j*r) respectively.
Here is what I have done so far. The for loop does not work but I cannot figure out how to deal with it.
[X, Y, Z] = textread('chmuratxt.txt','%f %f %f' ,1027846,'headerlines',1);
M = [X, Y, Z];
%resolution
r=0.2;
dx=max(X)-min(X);
dy=max(Y)-min(Y);
%number of raws
nr=round(dx/r);
% number of columns
nc=round(dy/r);
MZ=zeros(nr, nc);
for i=1:nr
for j=1:nc
[row,col] = find ((M(:,1), i > max(X)-(i*r) & i < max(X)-(i-1)*r)&(M(:,2), j > min(Y)+(j-1)*r & j < min(Y)+(j*r)));
end ;
end;

2 Kommentare

KSSV
KSSV am 6 Okt. 2017
Bearbeitet: KSSV am 6 Okt. 2017
How your formula have a min and max value and then indices? How you can compare them? They are different. Check your formula once. I assume, you should take the position/ index of max and min value rather.
Jan
Jan am 6 Okt. 2017
@amg: Do you see, that it does not matter, where the data are coming from? So mentioning this detail takes time only.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 6 Okt. 2017
Bearbeitet: Jan am 6 Okt. 2017

0 Stimmen

I guess, that you do not mean
i > max(X)-(i*r)
but
[maxV, maxIdx] = max(X);
i > maxIdx - (i * r)
and equivalent for the other expressions.
Or perhaps:
maxX = max(X); % Don't determine this in each iteration
minX = min(X);
dx = maxX - minX;
nr = round(dx/r); % Number of rows
...
for i = 1:nr
ix = minX + i * r;
for j = 1:nc
jx = minY + j * r;
idx = [??? Something with ix and jx ???]
[row, col] = find((M(:,1), idx));
end
end
I'm not sure.

Kategorien

Tags

Gefragt:

amg
am 5 Okt. 2017

Bearbeitet:

Jan
am 6 Okt. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by