Adding matrices (to assemble global stiffness matrix)
Show older comments
I want to add several 4X4 matrices into one large one, see code below on method. This is to assemble a global stiffness matrix of several bar elements. I will have 3 matrices to add into 1 large one, but I am stuck in modifying the code to add 3 4x4 matrices into one 6x6.
A simple example:
C = {[1,1;1,1],[1,1;1,1]}; % <- all matrices
N = numel(C);
M = zeros(1+N,1+N);
for k = 1:N, M(k:k+1,k:k+1) = M(k:k+1,k:k+1)+C{k}; end
M
M =
1 1 0
1 2 1
0 1 1
1 Comment
David Hill
on 22 Nov 2021
You will have to explain more fully what you want to do. Adding 3 4x4 matrices (total elements=48) into 6x6 matrix (total elements= 36), how are you suppose to do that? Where is the overlap between matrices?
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!