I have a big matrix B and I get it by concatenating the small matrices.
B = [A1 M1 M2 Z1
M1' M2' Z2 A2];
But when I store this matrix, its size is very big and it takes up a lot of memory. I want to convert it to sparse matrix. The matrices Z1 and Z2 have all zero elements and, M1 and M2 also have a lot of zeros.

댓글 수: 5

Alex Mcaulley
Alex Mcaulley 2019년 2월 26일
What is the question? you can use sparse function to convert your full matrix in sparse matrix
https://es.mathworks.com/help/matlab/ref/sparse.html
Should I convert the small matrices to sparse and then add them to the big matrix or Can I assemble B in such a way that it ends up being a sparse matrix?
B = [A1 M1 M2 Z1
M1' M2' Z2 A2];
Because with this code I can't get a sparse matrix. Is there another way to assemble this matrix?
Alex Mcaulley
Alex Mcaulley 2019년 2월 26일
yes, you should convert your small matrix to sparse and then combine them to obtain the sparse big matrix to avoid problems with memory
Jos (10584)
Jos (10584) 2019년 2월 26일
What do you want to do with B? In other words, do you really need to create it?
Ahmad Hasnain
Ahmad Hasnain 2019년 2월 26일
I use B in a quadratic equation. I need to multiply it with some vectors.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

태그

질문:

2019년 2월 26일

댓글:

2019년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by