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