How to make a slide windows?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Azzi Abdelmalek
le 3 Jan 2014
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))
Plus de réponses (1)
Walter Roberson
le 3 Jan 2014
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 commentaires
Voir également
Catégories
En savoir plus sur Matrix Computations dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!