How to refer current element index when using arrayfun

4 ビュー (過去 30 日間)
Randika Vithanage
Randika Vithanage 2018 年 2 月 15 日
コメント済み: Randika Vithanage 2018 年 2 月 15 日
Hi All,
I need to simplify below loop which is used to create a 3D point cloud. I'm thinking to use something similar to arrayfun or bsxfun. Could you please let me know how to get the index of current element? For example, in below loop Fdx, Dx, Fdy and Dy are constants. And j is the column ID of pixel and i is the row ID of the pixel.
Any line of advice is much appreciated.
for i=1:480
for j=1:640
Xd(i,j) = (Zd(i,j)/Fdx)*(j-Dx);
Yd(i,j) = (Zd(i,j)/Fdy)*(i-Dy);
end
end

採用された回答

Matt J
Matt J 2018 年 2 月 15 日
編集済み: Matt J 2018 年 2 月 15 日
Xd=bsxfun(@times,Zd,((1:640)-Dx)/Fx);
Yd=bsxfun(@times,Zd,((1:480).'-Dy)/Fy);
  1 件のコメント
Randika Vithanage
Randika Vithanage 2018 年 2 月 15 日
Many thanks Matt. It works.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by