overlapping different size matrices to make bigger matrix
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello, I am new to Matlab and I am developing a code to overlap matrices to make a bigger matrix.
My matrices are of different sizes, I have two matrices of 12x12 in a Struct and one matrix of 12x12 out of Struct. The matrix outside of Struct cannot be added inside the struct.
All three should overlap and make a matrix of 24x24.
S(1).model_data = sparse( rand( 12, 12 )) ;
S(2).model_data = sparse( rand( 12, 12)) ;
and
C = sparse( rand(12, 12));
The overlapping should be done as the last 6 columns of the first matrix and the first 6 columns of the second matrix should overlap, like this last 6 columns of the second matrix and the first 6 colmns of the third matrix should overlap.
I have written some code, but I cannot develop logic for it
s = size(S(1).model_data,1); % size of struct
n = size(S,2) ; % number of matrices in the struct
b = (s+(s-1)+(n-2)*(s-1)+(n-1))-6*(n-1); % size of resulting matrix
T = sparse(b,b) % resulting matrix
But I dont know how to add them diagnoally...
댓글 수: 1
James Tursa
2019년 11월 20일
Why can't you just add the individual pieces into the result spots that you want? What is the difficulty with doing this? Can you show a smaller example with numbers and desired result? E.g., for some 4x4 matrices.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!