Assembly of mass Matrix algorithm
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have this code, that generate the "Assembly of mass Matrix algorithm" this code deisgned for (3,3) matrix.
The problem is: how can i upgrade this code for (9*9) matrix.
%% assembly of the mass matrix
function M = MassMar2D(p,t)
clear,clc
p = [0 1 2 2 0;
0 0 0 1 1];
t = [1 1 2;
4 2 3;
5 4 4];
np = size(p,2); % number of nodes
nt = size(t,2); % number of elements
M = sparse(5,5); % allocate mass matrix
for K = 1:nt % loop over elements
loc2glb = t(1:3,K) % locate to global map
x = p(1, loc2glb); % node x-coordinates
y = p(2, loc2glb); % y
area = polyarea(x,y); % triangle area
MK = [2 1 1;
1 2 1;
1 1 2]/ 12 * area; % elements mass matrix
M(loc2glb, loc2glb) = M(loc2glb, loc2glb) ...
+ MK; % add element masses to M
end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!