フィルターのクリア

Adding coordinate values (x,y) to a matrix depending on another matrix

2 ビュー (過去 30 日間)
lauuser1
lauuser1 2016 年 4 月 27 日
回答済み: Walter Roberson 2016 年 4 月 27 日
There is one matrix that is a 10 x 10 that is initially all zeros.
matrix = zeros(10,10)
This matrix will eventually replace values of 0 with 1 until the whole matrix is made up of 1's.
There is another matrix that is an unknown number (L) x 2
track = zeros(L,2)
Now what I would like to do is populate track with coordinates whenever matrix changes from 0 to 1. So if a 1 is found in matrix in the 2nd row 1st column then the next value of 1 is in the 5th row 10th column, track will look like
track = [2 1; 5 10]
What is a possible way to do this?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 4 月 27 日
[tr, tc] = find(matrix);
track = [tr, tc];

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by