How to make a slide windows?
1 回表示 (過去 30 日間)
古いコメントを表示
Please help me out!
A = [ 1 2 3 4 5 6; 7 8 9 10 11 12 ; 13 14 15 16 17 18 ];
A =
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
B=[ 1 7 13 0 0 0 0 0; 0 2 8 14 0 0 0 0; 0 0 3 9 15 0 0 0 ; 0 0 0 4 10 16 0 0; 0 0 0 0 5 11 17 0; 0 0 0 0 0 6 12 18];
B =
1 7 13 0 0 0 0 0
0 2 8 14 0 0 0 0
0 0 3 9 15 0 0 0
0 0 0 4 10 16 0 0
0 0 0 0 5 11 17 0
0 0 0 0 0 6 12 18
Could I make this B matrix without for loop condition?
Please help me out!
0 件のコメント
採用された回答
Azzi Abdelmalek
2014 年 1 月 3 日
A = [ 1 2 3 4 5 6; 7 8 9 10 11 12 ; 13 14 15 16 17 18 ]
[n,m]=size(A)
B=[A' zeros(m,m-1)]
D=cell2mat(arrayfun(@(x) circshift(B(x,:),[0 x-1]),(1:m)','un',0))
その他の回答 (1 件)
Walter Roberson
2014 年 1 月 3 日
See the Example in http://www.mathworks.com/help/matlab/ref/diag.html for an example of filling the supra and super diagonal. You want k = 0, k = 1, k = 2
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Computations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!