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!