Creation of matrices (24,72) M1&M2 ?

6 views (last 30 days)
Hello. I want to create matrices (24,72) that have the following forms:

Accepted Answer

Stephen23
Stephen23 on 2 Feb 2016
Edited: Stephen23 on 3 Feb 2016
You can use blkdiag:
C1 = repmat({[1,1,0]},1,24);
M1 = blkdiag(C1{:});
And the second is either:
M2 = circshift(M1,[0,1]);
or
C2 = repmat({[0,1,1]},1,24);
M2 = blkdiag(C2{:});
  2 Comments
ET-TAOUSSI mehdi
ET-TAOUSSI mehdi on 2 Feb 2016
Thank you Stephen Cobeldick
Stephen23
Stephen23 on 3 Feb 2016
Another simple method is to use eye, zeros and reshape:
M1 = reshape([eye(24);eye(24);zeros(24)],24,72);
M2 = reshape([zeros(24);eye(24);eye(24)],24,72);

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!