separate x, y coordinate in a matrix into two different matrices
4 ビュー (過去 30 日間)
古いコメントを表示
I have 18 by 18 matrix with each cell has [-1;1] [-1;1] etc.. I want to separate this matrix into two 18 by 18 matrices. The first matrix would only have the first row for example, -1,-1 and the second matrix would have the second column for example 1, 1.
2 件のコメント
Walter Roberson
2015 年 10 月 5 日
I am not clear on what the size is of each element of the cell array?
回答 (3 件)
Walter Roberson
2015 年 10 月 6 日
x = cellfun(@(C) C(1), YourCell);
y = cellfun(@(C) C(2), YourCell);
0 件のコメント
Image Analyst
2015 年 10 月 5 日
Assuming it's a normal numerical matrix and not a cell array, try this:
firstRow = yourMatrix(1,:); % Extract first row.
secondRow = yourMatrix(2,:); % Extract second row.
2 件のコメント
Image Analyst
2015 年 10 月 5 日
Oh, sorry, you said you want the first row and the second column, not second row. To get the second column, you'd do this:
secondCol = yourMatrix(:, 2); % Extract second column.
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!