필터 지우기
필터 지우기

How to make a slide windows?

조회 수: 1 (최근 30일)
HYUNCHUL
HYUNCHUL 2014년 1월 3일
댓글: HYUNCHUL 2014년 1월 3일
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!

채택된 답변

Azzi Abdelmalek
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
HYUNCHUL
HYUNCHUL 2014년 1월 3일
Thank you so much for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
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

카테고리

Help CenterFile Exchange에서 Matrix Computations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by