overlapping different size matrices to make bigger matrix

2 visualizzazioni (ultimi 30 giorni)
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 Commento
James Tursa
James Tursa il 20 Nov 2019
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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by