-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCOM.m
More file actions
29 lines (21 loc) · 696 Bytes
/
COM.m
File metadata and controls
29 lines (21 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function COM = COM(n)
p = .0317; %g/cm^3
length = 35;
height = 10;
fun = @(y,z) p*(z./z);
funy = @(y,z) p*y.*(z./z);
funz = @(y,z) p*z.*(z./z);
zmin = @(y) 12.5*(abs(y)/4.5).^n;
deck = @(y) height*y./y;
boatdeck = @(y) zmin(y)-deck(y);
negboatdeck = fzero(boatdeck,-5);
posboatdeck = fzero(boatdeck,5);
totalmass = integral2(fun,negboatdeck,posboatdeck,zmin,deck)*length;
My = integral2(funy,negboatdeck,posboatdeck,zmin,deck)*length;
Mz = integral2(funz,negboatdeck,posboatdeck,zmin,deck)*length;
COMboat = 1:2;
COMboat(1) = My./totalmass;
COMboat(2) = Mz./totalmass;
COM = 1:2;
COM(1) = COMboat(1);
COM(2) = (totalmass * COMboat(2) + 0 * 300 + 3.3 * 720 + 25 * 100)/(totalmass + 1120);