How to evenly splice two block matrices together

8 views (last 30 days)
Given the block matrices
[A1, A2, A3, ... AN] and [B1, B2, B3, ... BN]
I would like to form
[A1, B1, A2, B2, A3, B3, ... AN, BN]
Is there a quick and dirty way to do this?
  4 Comments
Walter Roberson
Walter Roberson on 23 Jul 2019
Are you trying to form the block diagonal? blkdiag()

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jul 2019
The quick way is not to use individual variables for those. Put them in cell row vectors. Then
Temp = [Acell; Bcell] ;
Result = [Temp{:}] ;
The interleave logic relies on Acell and Bcell being 1xN cell arrays.
  1 Comment
Travis Arnold
Travis Arnold on 24 Jul 2019
This is the kind of solution I was looking for; I figured something with cell arrays would be the best solution. Thanks Walter!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!