2D Array Manipulation / Script
古いコメントを表示
I am looking to write a simple MATLAB script that will take any 2D array and double its size by duplicating every entry in the horizontal, vertical, and diagonal direction. The catch is I can not use for-loops. I have been thinking about using repmat(), but am unsure how this could translate to my problem.
For example, if I have a matrix A = [1 4 7 ; 8 9 3], then the result should be:
A=[
1 1 4 4 7 7
1 1 4 4 7 7
8 8 9 9 3 3
8 8 9 9 3 3
]
I hope I am articulating my thoughts well. Any help or tips would be greatly appreciated.
採用された回答
その他の回答 (1 件)
Matt Fig
2012 年 9 月 6 日
A = [1 4 7 ; 8 9 3],
expand(A,[2,2])
ans =
1 1 4 4 7 7
1 1 4 4 7 7
8 8 9 9 3 3
8 8 9 9 3 3
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!