-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfindMemberType3.m
62 lines (57 loc) · 2.36 KB
/
findMemberType3.m
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function [trussGraphOut, isPossible] = findMemberType3(trussGraph, safteyFactor)
%findMemberType finds the required member to hold the force
% please refer to some form of oracle if you need to understand the mess
% I am about to write
narginchk(1,2)
numIn = nargin;
memberForces = trussGraph.Edges.("Force in member");
tenStrengh = 230;%N edit this if you need to adjust how much a tension member holds
beamType = trussGraph.Edges.("Beam type");
safteyFactor_Members = trussGraph.Edges.("Safety Factor");
memLenghths = trussGraph.Edges.("Member Length");
if nargin == 2
tenStrengh = tenStrengh * safteyFactor;
end
[compressionTable, tensionTable, ~, ~] = generateTrussTables();
isPossible = true;
for i = 1:length(memberForces)
if memberForces(i) == 0
beamType(i) = {'Type 1 * 1'};
safteyFactor_Members(i) = inf;
elseif memberForces(i) < 0
if numIn == 2
compStrengh = findCompressionStrengths(memLenghths(i), safteyFactor);
else
compStrengh = findCompressionStrengths(memLenghths(i));
end
eqivTypeOne = abs(memberForces(i))./compStrengh;
posBeams = compressionTable((compressionTable.("Relative Strength")>eqivTypeOne),:);
if isempty(posBeams)
beamType(i)=compressionTable.("Member Type")(end);
safteyFactor_Members(i)=(compressionTable.("Relative Strength")(end)/eqivTypeOne);
warning('Truss unable to hold load')
isPossible = false;
break
else
beamType(i)=posBeams.("Member Type")(1);
safteyFactor_Members(i)=(posBeams.("Relative Strength")(1)/eqivTypeOne);
end
else
eqivTypeOne = memberForces(i)./tenStrengh;
posBeams = tensionTable((tensionTable.("Relative Strength")>eqivTypeOne),:);
if isempty(posBeams)
beamType(i)=tensionTable.("Member Type")(end);
safteyFactor_Members(i)=(tensionTable.("Relative Strength")(end)/eqivTypeOne);
warning('Truss unable to hold load')
isPossible = false;
break
else
beamType(i)=posBeams.("Member Type")(1);
safteyFactor_Members(i)=(posBeams.("Relative Strength")(1)/eqivTypeOne);
end
end
end
trussGraph.Edges.("Beam type") = beamType;
trussGraph.Edges.("Safety Factor") = safteyFactor_Members;
trussGraphOut = trussGraph;
end