Say I have three different 2×2 submatrices, and I want to create a big 6×6 matrix in Matlab in which the three submatrices appear on the diagonal, and all the other values are 0. How can I do this wihtout entering all the zeros explicitly? I just started learning MatLab and I really am quite a novice. If someone could help me with this I would be very grateful! Later I have to do this with more matrices, and entering all the zeros is becoming a pain!
Share
Suppose your matrices are named
M1,M2,M3, writeblkdiag(M1, M2, M2). If any of your matrices is sparse, so will be the result. Otherwise it will be dense.