フィルターのクリア

How do I map the elements of one matrix to another?

3 ビュー (過去 30 日間)
Noah Huffman
Noah Huffman 2017 年 7 月 20 日
編集済み: Stephen23 2017 年 7 月 20 日
I am trying to transform a matrix A to A' where the indices are transformed by:
  • y' = x
  • x' = 1024-y
I am currently using the code:
for x = 1:1024
for y = 1:1024
f{x,y} = b(1024-y,x);
end;
end
but am getting a "Subscript indices must either be real positive integers or logicals." error. Any suggestions on how to do this?

採用された回答

Stephen23
Stephen23 2017 年 7 月 20 日
編集済み: Stephen23 2017 年 7 月 20 日
If b has 1024 rows then you will need:
1+1024-y
otherwise the lowest calculated index value will be zero (MATLAB indexing starts at one).
Better alternative: doing this in a loop is likely not very efficient, you should simply use indexing directly, e.g.:
fliplr(b.')
or
b(end:-1:1,:).'
and then wrap it in num2cell.
  2 件のコメント
Noah Huffman
Noah Huffman 2017 年 7 月 20 日
Thanks a ton!
Stephen23
Stephen23 2017 年 7 月 20 日
編集済み: Stephen23 2017 年 7 月 20 日
@Noah Huffman: you can say thank you by accepting the answer that best resolves your original question. Accepting an answer gives that volunteer reputation points and also shows that the question has been resolved.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by