Say I have three different 2x2 submatrices, and I want to create a big 6x6 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!
Suppose your matrices are named M1, M2, M3, write blkdiag(M1, M2, M2). If any of your matrices is sparse, so will be the result. Otherwise it will be dense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With