Borrar filtros
Borrar filtros

How to make a slide windows?

2 visualizaciones (últimos 30 días)
HYUNCHUL
HYUNCHUL el 3 de En. de 2014
Comentada: HYUNCHUL el 3 de En. de 2014
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!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 3 de En. de 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))
  1 comentario
HYUNCHUL
HYUNCHUL el 3 de En. de 2014
Thank you so much for your help!

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 3 de En. de 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

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by