I have a vector of X coordinates and a vector of Y coordinates that together form a closed shape. This shape is plotted in a larger window of other shapes and pictures. I want to create a matrix that can be overalyed on the aforementioned larger window and referenced whose only values are ones and zeros. I want the ones to be the shape created by the X and Y vectors and everything inside it, and the zeros to be everything else. Any ideas for how to do this efficiently? The goal is to have a matrix that can be referenced against the original window that only contains the information on the space occupied by the one specific shape.

回答 (1 件)

Matt J
Matt J 2021 年 6 月 21 日
編集済み: Matt J 2021 年 6 月 21 日

0 投票

As long as X and Y are matrix indices, you can do
matrix=accumarray([X(:),Y(:)],1,targetSize);
where targetSize is the desired size of the resulting matrix.

カテゴリ

ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索

製品

リリース

R2021a

タグ

質問済み:

2021 年 6 月 21 日

編集済み:

2021 年 6 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by