Download presentation
Presentation is loading. Please wait.
1
EGR 106 – Project Intro / While Loop Project description Project schedule Background information / terminology A simple example Examples of similar programs While loop
2
Working in teams of approx. four students, each team is to develop a Matlab program that can be used to design a lightweight truss structure The code shall allow the designer to evaluate alternative designs quickly and easily The actual truss analysis will be performed by the Matlab function “truss_analysis.m” to be provided by the instructor. Project Description
3
The program developed by each team shall provide a user-friendly interface for both data input and interpretation of results Each team’s code will be used in a design competition in which each team will be given 1 hour to develop a truss design for a particular load scenario The team will then construct their design from balsa wood (required construction materials will be provided) Project Description (cont.)
4
3/27 – (T)Project Introduction 3/29 – (R)Quiz 2 make up / Team assignment #1 4/3 – (T)Lecture: Analysis of Trusses / Graphical Interface 4/5 – (R)Project work / Team assignment #2 4/10 – (T)Lecture: Analysis of Trusses / Graphical Interface 4/12 – (R)Quiz 3 / Project work 4/17 – (T)Project work 4/19 – (R)In-class design competition 4/24 – (T)Quiz 4 / Model testing 4/26 – (R)Project Presentations / Demonstrations 5/1 – (T)Written reports due Project Schedule (tentative)
5
Definition: A planar truss is a structure composed of slender members joined together at their end points (called joints). Background – Truss Structures Photo: Engineering Mechanics: Statics, by R. C. Hibbeler
6
Terminology – Truss Structures Forces Joint Member Supports
7
Trusses are supported at certain joints at which motion is constrained either in the x- direction, y-direction or both the x- and y-directions. These supports are also called boundary conditions. Terminology (cont.) X & Y –displacement=0 X - displacement=0 Y -displacement=0 (bctype=1) (bctype=2) (bctype=3)
8
Truss Analysis – A simple example C x = 100 C y = -50 300 mm 150 mm
9
A simple example – input data (details to be discussed next class) C x = 100 C y = -50 300 mm 150 mm joint_def=[0, 0, 1, 0, 0; 50, 50, 0, 0, 0; 150, 150, 0, 100, -50; 250, 50, 0, 0, 0; 300, 0, 3, 0, 0; 200, 0, 0, 0, 0; 100, 0, 0, 0, 0]; member_def=[1, 2, 10, 10; 2, 3, 10, 10; 3, 4, 10, 10; 4, 5, 10, 10; 5, 6, 10, 10; 6, 7, 10, 10; 7, 1, 10, 10; 2, 7, 10, 10; 7, 3, 10, 10; 3, 6, 10, 10; 6, 4, 10, 10];
10
Joint Displacments disp = 0.0000 0.2457 -0.1750 0.6493 -0.4371 0.2043 -0.4578 0.4500 -0.0000 0.3000 -0.5536 0.1500 -0.2707 C x = 100 C y = -50 300 mm 150 mm Member Stresses stress = 0.3536 -1.0607 0.7500 -0.0000 0.0000 -0.0000 A simple example - results Matlab command (call to function ‘analyze_truss’): [disp,stress]=analyze_truss(joint_def,member_def)
11
Examples of truss design programs Johns Hopkins University: http://www.jhu.edu/~virtlab/bridge/truss.htm West Point Bridge Design Contest http://bridgecontest.usma.edu/
12
Notes on academic integrity Truss design and analysis programs are common. Students are welcome to look at other programs for features to incorporate. Direct copying of code, however, is not permitted. Do not share code with other teams. Be sure not to leave your codes on public computers.
13
Longer Running Loops for loops repeat a fixed number of times: for variable = {array of length n} {commands} end and break can be used to stop earlier. Question: How about repeating “until done”? Run as long as is needed.
14
Answer: M ATLAB ’s “while” loop: while expression {commands to be repeated as long as expression is true} end
15
Prior example – compounded interest until the amount doubles: value = 1000; for year = 1:1000 value = value * 1.08; disp([num2str(year),' years: $ ',num2str(value) ]) if value > 2000 break end for loop terminated with break
16
Expected output:
17
while version format bank value = 1000; while value < 2000 value = value * 1.08; disp(value) end
18
Example – Collecting and storing data until a zero is entered: x = [ ]; new = 1; while new ~= 0 new = input('enter value '); x = [ x, new ]; end x = x(1:end–1) empty array to drop the zero initialize
19
Example – Getting valid keyboard input: E.g. forcing the user’s input to be between 0 and 10: x = –3; while ( x 10 ) x = input( 'type a value ' ); end
20
or: x = input('enter value '); while (x 10) disp('invalid choice'); x = input('enter value '); end disp('finally!');
21
Example – computing pi:
22
Example – “infinite” Hi-Lo: numb = round (10*rand(1)); done = 0; while ~done guess = input('guess'); if guess = = numb disp( 'You got it !!!' ); done = 1; elseif guess > numb disp('too high') else disp('too low') end initialization single guess loop control
23
Nesting of while loops while expression1 {outer loop commands} while expression2 {inner loop commands} end {more outer loop commands} end these can also be more than 2 levels deep
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.