Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Special Topics in Computer Applications in Engineering and Construction Exam, Exams of Civil Engineering

An exam for the cven 489-502 (302 - socolofsky) course at texas a&m university. The exam covers topics such as programming and numerical methods in engineering and construction. It includes true or false, multiple-choice, and workout problems that require the use of matlab to solve.

Typology: Exams

2010/2011

Uploaded on 05/18/2011

limepacerz08
limepacerz08 🇺🇸

7 documents

1 / 12

Toggle sidebar

Related documents


Partial preview of the text

Download Special Topics in Computer Applications in Engineering and Construction Exam and more Exams Civil Engineering in PDF only on Docsity! CVEN 489-502 (302 - Socolofsky) Special Topics in Computer Applications in Engineering and Construction Exam #1: Introduction to Programming and Numerical Methods October 9, 2009, 10:20 am–12:10 pm in Zachry 127B Name: : UIN: : Instructions: Fill in your name and UIN in the space above. There should be two packets: one with true/false and multiple choice questions, and a second with workout problems. The exam is closed book, and only one double-sided sheet of notes is permitted. No collaboration with others! For multiple choice questions, choose the single, best answer. For short answer and workout problems, write down all steps necessary to solve the problem: show all your work. Failure to do so will result in a lower score. Be sure to answer all parts of all problems. Do not leave any problems blank. Certification: “An Aggie does not lie, cheat, or steal or tolerate those who do.” By my signature below, I certify that the work contained in this exam is my own and that I did not receive help from other students. Signature: Date: CIVIL College Station, Texas 77843-31363136 TAMU (979) 845-4517 FAX (979) 862-8162 A. True or False For each of the following statements, check the box with the most appropriate response. Worth 20 point: problems are 2 points each. 1. Two Matlab commands to get help from the command line are help and lookfor 2 True 2 False 2. A proper Matlab statement to evaluate x2 √ y2 + x2 sin(ωt− φ) (1) is ans = x^2 * sqrt(y^2 + x^2) / sin(w*t - phi), where x, y, w, t, and phi are vari- ables storing a single number. 2 True 2 False 3. If x = 7, y = 10, and z = 3.5782, then the following statement evaluates to ( x == y || y > z ) && ~( x > y ) 2 True 2 False 4. The Matlab load command can load data from text files containing numbers and letters. 2 True 2 False 5. It is good programming practice to use arbitrary variable names that are not descriptive since they are less likely to overwrite built-in Matlab functions. 2 True 2 False 6. An IF-block executes the code under each statement that evaluates true. For instance, the result of this code x = 5; y = 2; if x > 0 x = 7; elseif y < 10 y = 5; end will be to set x = 7 and y = 5. 2 True 2 False 7. It is good programming practice to indent code to show the structure of loops and branches. 2 True 2 False 2 16. Which of the following is good programming practice? a. Never modify the values of a FOR-loop index while inside the loop b. Do not test your program until it is complete in all of its components c. Copy and paste code whenever you need to reuse it d. Ignore formatting conventions: Matlab does not read them anyway e. Name all variables after Disney characters since they are easy to remember 17. Which of the following is an acceptable thing to do in good Matlab programming? a. Name your program plot.m b. Clear the memory before running a new program c. Type f(x) = x.^2 in the command window d. Name your program lab-1.m e. Type y + 7 = x in the command window 18. You have the following code: x = 0:0.01:10; n = length(x); A = zeros(n,n); A(:,1) = 1; for id = 2:n A(:,id) = A(:,1) + x(id+1); end What is wrong with this code? a. A(:,1) = 1 is not a valid Matlab command b. id is not a valid name for a loop variable: use i instead c. The code inside the loop will overrun the number of data points in the variable x d. A = zeros(n,n) is unnecessary since the FOR-loop will fill the components of A e. The code contains no errors 5 19. Given the following array in Matlab: A = [1 17 8 4; 24 3 0 NaN; 35 27 Inf 9]; what is A(2,3)? a. 0 b. Inf c. NaN d. 27 e. The expression for A is not valid since it contains letters and numbers 20. Which of the following statements is false about a .m-file whose first line of executable code is function [f0, test] = my_function(x, p, omega) a. omega is an input to the function b. The body of the function must have a line that sets the value of f0 c. An acceptable usage of this function at the Matlab prompt would be [f, test] = my_function(10, 7, w) d. The filename must be my function.m e. An appropriate command inside the function would be x = 7 21. Which of the following is an acceptable variable name in well-written Matlab code? a. n-iter b. number-of-iterations c. number>iterations d. n iterations e. n iterations 22. Which of the following is true about a Matlab FOR loop a. FOR loops can run forever if you are not careful b. The loop variable will be an array c. Matlab automatically changes the value of the loop variable each time the loop iterates d. You cannot put other loop structures inside a FOR loop e. FOR loops are faster than their vectorized equivalents 6 23. Which of the following is not a Matlab keyword a. iter b. end c. for d. while e. if 24. Which of the following is a poor use of commenting in well-written Matlab code? a. Including a variable dictionary at the top of your code b. Giving the units of variables as they are defined c. Providing comments that will be echoed to the command window when the help com- mand is invoked by the user d. Keeping a record of revision edits to your program e. Collecting all comments to the top of a file so that Matlab commands are not cluttered with comments 25. You have the following code, where xx.dat is a file consisting of a single column of numbers: x_data = load(’xx.dat’); n = length(x_data); j = 0; for k = 1:n if x_data(k) < -9990 x_data(k) = NaN; j = j+1; end end What does this code do? a. Scans the data in x data for values less than -9990 and replaces them with the not-a- number flag b. Counts the number of flagged data points using the variable j c. Generates an error from the load command if the file xx.dat has any missing rows d. All of the above e. Only a. and b. 7 D. Workout Problem For the workout problem, please show all your work and submit your solution in the space provided. Do not forget any parts of the problem. Worth 30 points. 29. A data file grades.dat contains 11 columns of data: The first column is a list of student UIN numbers, the remaining columns report the grades (on a scale of 0 to 100) for each student on 10 assignments. Write a Matlab Program that does the following a. Read in the data file b. Scan through each row to find the lowest grade for each student. Then scan through the data a second time to replace the lowest grade with the value -2. Excused absences are already recorded as -1 in the data file. Values less than zero indicate grades that are not to be counted in the average. c. Compute the average grade for each student using the remaining valid scores (filter out all negative scores). The average x for a set of data points x should be computed from x = 1 n n∑ i=1 xi (4) Be sure to divide by the correct number n of counted assignments for each student. The remainder of this page is provided for your own notes and brainstorming. This page will NOT be graded! 10 i. Write the code here to load the data, find the lowest grade, and replace the lowest grade with the value -2 (15 points). 11 ii. Write the code here to compute the average (15 point). 12
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved