필터 지우기
필터 지우기

Assembly of mass Matrix algorithm

조회 수: 3 (최근 30일)
Lamour Haithem Firass
Lamour Haithem Firass 2021년 5월 16일
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개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by