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

KSSV
KSSV 2017년 10월 6일
편집: KSSV 2017년 10월 6일
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 2017년 10월 6일
@amg: Do you see, that it does not matter, where the data are coming from? So mentioning this detail takes time only.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2017년 10월 6일
편집: Jan 2017년 10월 6일

0 개 추천

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.

카테고리

도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

amg
2017년 10월 5일

편집:

Jan
2017년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by