overlapping different size matrices to make bigger matrix
2 次查看(过去 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!