Download presentation
Presentation is loading. Please wait.
1
EGR 106 – Truss Design Project (cont.) Truss design programs Graphical interface tools in Matlab Saving and loading data Formatted output Project Assignment – part #2
2
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/
3
Graphical Interface Tools The function draw_truss will be provided to allow for graphical input of joint coordinates and member definitions To use this function: – Download the file draw_truss.m from the course web page and save it in your current directory – Include the following command in your code: [joint_def,member_def]=draw_truss
4
Graphical Interface: the function draw_truss
5
Saving data: – save filename – save filename array1 array2 – save filename –ascii Importing/Exporting Data Reading in (loading) data: – load filename – load filename array1 array2 – load filename –ascii
6
Importing/Exporting Data - example Saving arrays to file: >> clear >> a=[1 2 3; 4 5 6] a = 1 2 3 4 5 6 >> b=[7 8 9] b = 7 8 9 >> save arrays_a_and_b a b Loading arrays from a file: >> clear >> load arrays_a_and_b a b >> a a = 1 2 3 4 5 6 >> b b = 7 8 9 Creates file arrays_a_and_b.mat
7
Formatted output Formatted print command: fprintf(format,data) – Combines text and data – Allows complete control of the output – format is a string (in quotes) containing text and control commands (using \ or %) – See text pages 87-94 for more details
8
An example: %d = put data here \n = new line The data itself Formatted output (cont.)
9
Escape characters: – New line ( \n ), backspace ( \b ), tab ( \t ), … Formatted output (cont.)
10
Conversion codes for data: – Decimal ( %d ), character ( %c ), exponential notation ( %e ), fixed precision ( %f ), … – Can add field width and precision information: 5 characters wide, 2 after the decimal point Formatted output (cont.)
11
fprintf works element-by-element on array data: \n added for line return Formatted output (cont.)
12
To write to a file: fid = fopen( 'name', 'w' ) fprintf(fid,format,data) … fclose(fid) – fid is a variable name to specify which file – name is the name of the file w indicates “write” Formatted output to a file
13
Truss Project – Assignment #2* Starting with your code from assignment #1: – Allow user to load results from previous design – Use function draw_truss to create new design – Develop code to allow user to define boundary conditions, forces and member width and thickness – Compute total length of members, mass of each member and total mass of truss – Allow user to save truss design – Have code create output file summarizing design parameters – Look for additional features to make your code more user friendly * See handout for details
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.