replace element in matrix with matrix

3 ビュー (過去 30 日間)
Nitin Sapre
Nitin Sapre 2019 年 10 月 10 日
回答済み: Rik 2019 年 10 月 10 日
i have a matrix say example
with expansion factor 3 i.e each element in matrix should be replaced by the identity matrix of order 3x3 and depending on matrix element it will circular shift by the lement of matrix
e.g i have a matix [2 1 0,-1 0 2, 1 0 0] >>>>>>> -1 will be replaced by all zero matrix of order 3x3
>>>>>> 0 will be the identity matrix of order 3x3; 1 is the identity matrix of order 3x3 but circ shift by 1 && 2 the identity matrix of order 3x3 cirshift by 2
please let know any ideas to do this
thanks

採用された回答

Rik
Rik 2019 年 10 月 10 日
(written on mobile, untested code)
Out=cell2mat(arrayfun(@(x) circshift(eye(3),x),'UniformOutput', false));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Operations and Transformations についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by