-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutput.m
More file actions
248 lines (172 loc) · 4.39 KB
/
Copy pathOutput.m
File metadata and controls
248 lines (172 loc) · 4.39 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
load('RealTruss1_MarkDeaFelix_A3.mat');
%making matrix Ac
Lengths = CalcLength(X,Y,C);
A = MakeMatrixA(C,X,Y,Lengths,Sx,Sy);
%solving for Tensions
Ainv = inv(A);
T = Ainv*L;
%meters to inches
%Lengths = Lengths*39.37;
%Pcrit / Buckling Strength
for i = 1:length(Lengths)
Pcrit(i) = 2990/(Lengths(i)^2);
end
%creating SR
for i = 1:length(Lengths)
SR(i) = -(T(i)/(2990/(Lengths(i))^2));
end
load = sum(L);
Wfail = load / (max(SR)); %max theoretical load
maximumSR = max(SR); %maxSR
%which number fails
memfail = find(SR==maximumSR); %which member fails
%total cost
[r c] = size(C);
Cost = (10*r) + (1*sum(Lengths));
%load to cost ratio
loadtocost = Wfail / Cost;
%lets print
fprintf('EK301, Section A3, Group The Buckling Bucklers: Mark V, Dea T, Felix F,11/23/2020 \n\n');
fprintf('Load: %.2f oz \n\n',max(L));
fprintf('Member forces in Ounces for LIVE LOAD \n');
%prints members and their tensions/compressions
for i = 1:c
if T(i) < 0
word = "(C)";
elseif T(i) > 0
word = "(T)";
elseif T(i) == 0
word = "";
end
fprintf('m%d: %.3f %s \n',i,abs(T(i)),word);
end
fprintf('\n');
%print reaction forces
fprintf('Reaction forces in Ounces for LIVE LOAD: \n');
[rx cx] = size(Sx);
[ry cy] = size(Sy);
countx = 0;
for i = 1:rx
for j = 1:cx
if Sx(i,j) == 1
countx = countx + 1;
end
end
end
county = 0;
for i = 1:ry
for j = 1:cy
if Sy(i,j) == 1
county = county + 1;
end
end
end
%prints Sx and Sy
for i = 1:countx
fprintf('Sx%d: %.2f \n',i,T(length(Lengths)+i));
end
for j = 1:county
fprintf('Sy%d: %.2f \n',j,T(length(Lengths)+i+j));
end
fprintf('\nCost of truss: $%.2f\n',Cost);
fprintf('Theoretical max load/cost ratio in oz/$: %.4f\n\n\n',loadtocost);
%PRINTING OUR CM
fprintf('Our Cm for our members \n');
%prints members and their Cms
for i = 1:c
fprintf('m%d: %.3f \n',i,abs(T(i))/max(L));
end
fprintf('\n\n');
%%PRINTING WDEAD
%solving for Tensions
Ainv = inv(A);
Tdead = Ainv*Ldead;
fprintf('Member forces in Ounces for the DEAD LOAD \n');
%prints members and their tensions/compressions
for i = 1:c
if Tdead(i) < 0
word = "(C)";
elseif Tdead(i) > 0
word = "(T)";
elseif Tdead(i) == 0
word = "";
end
fprintf('m%d: %.3f %s \n',i,abs(Tdead(i)),word);
end
fprintf('\n');
%print reaction forces
fprintf('Reaction forces in Ounces for DEAD LOAD: \n');
[rx cx] = size(Sx);
[ry cy] = size(Sy);
countx = 0;
for i = 1:rx
for j = 1:cx
if Sx(i,j) == 1
countx = countx + 1;
end
end
end
county = 0;
for i = 1:ry
for j = 1:cy
if Sy(i,j) == 1
county = county + 1;
end
end
end
%prints Sx and Sy
for i = 1:countx
fprintf('Sx%d: %.2f \n',i,Tdead(length(Lengths)+i));
end
for j = 1:county
fprintf('Sy%d: %.2f \n',j,Tdead(length(Lengths)+i+j));
end
%REAL LOAD DATA
Treal = T + Tdead;
%creating SR
for i = 1:length(Lengths)
SRnom(i) = -(Treal(i)/(2990/(Lengths(i))^2));
SRweak(i) = -(Treal(i)/(2990/(Lengths(i))^2 - 20));
SRstrong(i) = -(Treal(i)/(2990/(Lengths(i))^2 + 20));
end
Lreal = L + Ldead;
loadreal = sum(Lreal);
Wfailnom = loadreal / (max(SRnom));%max theoretical load
Wfailweak = loadreal / (max(SRweak));
Wfailstrong = loadreal / (max(SRstrong));
maximumSRreal = max(SRnom); %maxSR
%which number fails
memfailreal = find(SRnom==maximumSRreal); %which member fails
%Printing our Wnom, Wstrong, Wweak
fprintf('\nWlNom: %.2foz\n',Wfailnom);
fprintf('Wlweak: %.2foz\n',Wfailweak);
fprintf('Wlstrong: %.2foz\n',Wfailstrong);
%FUNCTIONS
function Lengths = CalcLength(X,Y,C)
[~,members] = size(C);
Lengths = zeros(members,1);
for i = 1:members
points = find(C(:,i));
p1 = points(1);
p2 = points(2);
deltaX = X(p2) - X(p1);
deltaY = Y(p2) - Y(p1);
Lengths(i) = sqrt(power(deltaX,2) + power(deltaY,2));
end
end
function A = MakeMatrixA(C, X, Y, Lengths,Sx,Sy)
[joints,members] = size(C);
Ax = zeros(joints,members);
Ay = zeros(joints,members);
for i = 1:members
points = find(C(:,i));
p1 = points(1);
p2 = points(2);
length = Lengths(i);
Ax(p1,i) = (X(p2)-X(p1))/length;
Ax(p2,i) = (X(p1)-X(p2))/length;
Ay(p1,i) = (Y(p2)-Y(p1))/length;
Ay(p2,i) = (Y(p1)-Y(p2))/length;
end
A = [Ax Sx; Ay Sy];
end