ENGR 1181 | Final Exam: Study Guide and Practice Problems Disclaimer Problems seen in this study guide may resemble problems relating mainly to the pertinent homework assignments. Reading this study guide and solving the practice problems is not a sufficient level of studying for this exam. Students should also review the relevant reading material and PowerPoint slides as questions will be asked from those places as well. Please remember that the number of “show your work” practice problems exceeds the number of “show your work” exam problems. Exam Specifications 100 Points Total - 20 points multiple choice (10 questions, 2 pts. each) o Done on Carmen using a “lockdown browser” o No other internet access is allowed. Those accessing the internet otherwise will be sent to COAM. Please review OSU’s policy on academic misconduct. o Graded automatically and entered into Carmen, your score will be visible but any missed problems will not be shown immediately after the exam is over. - 80 points – 3 “show your work” problems - o All problems will be done in MATLAB, you will create the script files. Always start your script files by displaying your name, seat number etc. and using close all; clear; clc o Make sure you assign a different name for each PDF file during the exam. o Do not use “run section” during the exam, it will not save your script file and your work will be lost! ALWAYS use “run”. Calculators are not allowed. The exam is closed book closed notes. No communication with other students is allowed. Please review OSU’s policy on academic misconduct. No use of cell phones. Name: Seat Number: __________ Content Review - Below is contained the content and learning objectives that will be tested on this exam. Not all learning objectives will be tested exactly as read, however students should use this material to keep track of what they need to be reviewing. 1. MATLAB a. Array Creation i. [a, b, c ; d, e, f] notation ii. [min : step : max] notation iii. linspace function iv. I/O Associated learning objectives Demonstrate proper usage of basic MATLAB features (e.g., the Command Window, script files, other default windows, arithmetic operations, assigning variables and names, built-in functions, help command) Demonstrate proper notation for accessing elements from previously assigned onedimensional arrays (e.g., single elements, list of elements) and two-dimensional arrays (e.g., those with rows and columns) b. Array Accessing i. Pure array accessing ii. Sub arrays iii. Using the colon operator Associated learning objectives Demonstrate proper notation for accessing elements from previously assigned onedimensional arrays (e.g., single elements, list of elements) and two-dimensional arrays (e.g., those with rows and columns) Explain that a string is a one dimensional array and can be used the same way as numeric arrays c. Array Operations (“.” Operators) Associated learning objectives Explain meaning of element-by-element operations Identify situations where the standard operators in MATLAB (when used with arrays) are reserved for linear algebra, which is not always element-by-element Apply dot operators for o The six cases where linear algebra is not element-by-element and therefore dot operators are needed to produce element-by-element calculations Name: Seat Number: __________ d. MATLAB algebra syntax (conversion from math expression) Associated learning objectives Explain meaning of element-by-element operations Identify need to translate mathematical notation into proper MATLAB syntax e. Conditional Statements and logical operators Associated learning objectives Explain how conditional statements (e.g., if-end, if-else-end, switch-case) are used to make decisions Apply logical operations correctly in arrays Analyze data using logical operators. f. MATLAB looping Associated learning objectives Use more complex ways of setting the loop index Use loops to repeat a code with conditional statements g. Functions Associated learning objectives Demonstrate the proper use of functions in their programs Explain how functions can be used in multiple places and as an organizational tool Describe purpose and structure of a function definition line Integrate user-written functions into the same file with the main program Identify good function conventions, (e.g., the importance of placing functions at the end h. Plotting Associated learning objectives Create scatter plots in MATLAB with good graphing conventions (e.g., legend, linestyles, title, multiple plots on same graph) Create other 2D graphing options in MATLAB (e.g., log, bar, subplot, fplot) Select the proper opportunities to utilize aforementioned 2D graphing options i. Other Associated learning objectives Perform simulations using MATLAB programming skills that have been learned thus far Identify the limitations of computer based solutions Illustrate how the real-world responds to the development of and limitations of computer solutions Name: Seat Number: __________ 2. Labs a. Quality and productivity Associated learning objectives Describe how an engineer can help enhance productivity, speed, quality, cost and sustainability in the manufacturing process. Identify the core, fundamental principles of Lean (eliminating waste) and Sigma (reducing variation in the product). Explain the fundamental difference between PUSH and PULL systems on the assembly line. b. Circuits i. Ohm’s law ii. Series and parallel resistors iii. Voltage drop Associated learning objectives Recognize and assemble series and parallel circuits. Construct electric circuits using a breadboard. Demonstrate how voltage, current and resistance are measured. Identify and use Ohm’s Law, Power Law, Kirchhoff’s Current Law and Kirchhoff’s Voltage Law. Calculate and measure the equivalent resistance of electric circuits. Employ the proper circuit configuration for a given scenario. c. Solar Meter Associated learning objectives Describe and build both a calibration and solar meter circuit Convert decimal values to binary values Compare a pictorial image of a circuit to a schematic wiring diagram d. Solar Cell Associated learning objectives Identify the advantages and disadvantages of solar cells. Calculate the efficiency of a solar cell. e. Beam Bending Associated learning objectives Employ the concepts of stress, strain, and Young's modulus for structural materials. Use the stress-strain equation to calculate how applied forces deform structures. Calculate the moment of inertia of various beam geometries. Determine how beam geometry affects the stiffness and strength of beams. Identify unknown beam material through analysis and calculation of Young’s Modulus. Name: Seat Number: __________ f. Evaluate behavior of various beams based on material and shape. Wind Turbine – part A Associated learning objectives Describe the relationship between velocity (of the wind) and pressure based on Bernoulli’s Equation for incompressible flow. Calculate the power available in the wind and compare it to the power generated by a wind turbine. Summarize the characteristics of the wind tunnel and turbine. Describe the relationship between velocity (of the wind) and pressure. Determine the power available in the wind. Relate the power available in the wind to the wind speed. Compare the power generated by a wind turbine to the power in the wind. g. Train Project Associated learning objectives Use train project functions to program train and gate motions Solve complex train project statement problem involving previously used concepts Apply knowledge of “tic” and “toc” to solve problem in real-time programming Here is a syntax guide for help in reviewing. PRINTING AND BRINGING THIS TO THE EXAM IS NOT ALLOWED. MatLab Syntax Review Sheet – FOR MIDTERM 2 RELEVANT INFORMATION ONLY Current Directory – your current working directory with a list of m-files Workspace – current list of MatLab variables and values Command History – past commands that have been typed and executed Command Window – where commands can be entered Editor Window – where you write and run MatLab script files Don’t forget that typing “help” into MATLAB will assist you with specific functions and is allowed during the exam “show your work” problems! MatLab Tips Name: Seat Number: __________ >> clc clear command window; does not clear memory >> cmd displays the result of a command in the command window >> cmd; does not display the result in the command window >> cmd1, cmd2 displays both results >> cmd1; cmd2 displays last result only clear clears ALL variables from memory clear x,y,z clears only x, y, and z variable names 2. must begin with a letter 3. are case sensitive contain letters, numbers, and _ math precedence ... (ellipsis) highest → ( ) ; ^ ; * / ; + - ← lowest 4. extends a command to the next line up arrow ↑ scrolls backward through previous commands down arrow ↓ scrolls forward through commands help abcd help on the subject "abcd" ( doc abcd -- works too ) Numeric Display Formats format short nnn.1234 format long nnn.12345678901234 (14 decimal places) format short e n.1234e+001 format bank nnn.12 Input / Output Commands disp( ' any text ' ) displays ' any text ' in the command window fprintf('Text = %i,%f',k,x) formatted output – prints "Text = integer and fixed point" x = input( ' any text ' ) asks the user to enter a value for x from the keyboard 1-D Array (row and column vectors) scalar, s is a single number (a 1 x 1 array) vector, v is a 1 row x n column array a list of numbers v_list = [ a b c ] or = [ a , b , c ] row vector v_row = [ a b c ] or = [ a , b , c ] column vector v_col = [ a ; b ; c ] constant spacing v_space = [ first : space : last ] single spacing v_1space = [ first : last ] vector with n terms, evenly spaced v_nterms = linspace( first, last, n ) Name: Seat Number: __________ transpose of a vector v_col = v_row ' value of the ith term v(i) Addition / Subtraction z = x y z = [ 𝑥1 𝑦1 , 𝑥2 𝑦2 , 𝑥3 𝑦3 ] Multiplication / Division z = x .* y and z = x . / y Exponents z = x .^ y z = [ 𝑥1 . ^ 𝑦1 , 𝑥2 . ^ 𝑦2 , 𝑒𝑡𝑐. ] max(v) or min (v) Returns largest / smallest element of v length(v) Returns the length (# of elements) in vector v mean(v) or sum(v) Returns average value / sum of elements in v 2-D Array (matrix) Matrix, A is an r (rows) X c (columns) array A( r, c ) is the value of the element ( r, c ) in A A( r, c ), in rows A = [ row1 ; row2 ; row3 ] A( r1:r2, c1:c2 ) retrieves values in row and column ranges Example: A(1:3, [1 4 6]) means rows 1-3 and columns 1,4,6 of matrix A Logic – Conditional and Relational Operators Less than / Greater than < / > Less than equal to / greater than equal to <= / >= Equal to / Not equal to == / ~= TRUE statement / FALSE statement 1 (or any non-zero number) / 0 & AND ( Example: A & B ) TRUE when A and B are both true | OR ( Example: A | B ) TRUE when either A is true or B is true ~ NOT ( Example: ~ A ) TRUE if A is false / FALSE if A is true Operator precedence ( high low ) ( ) ^ ~ */ +– > < >= <= == ~= & | Conditional Statements if conditional statement Command Group end Works when there is only one command group Name: Seat Number: __________ if conditional statement If the conditional statement is "True", then do "Command Group 1". Command Group 1 It the conditional statement is "False", then do "Command Group 2". else Command Group 2 end if ( conditional 1 ) "If – elseif – else – end" do Command Group 1 elseif ( conditional 2 ) When there are more than two command groups, you can use this form with elseif do Command Group 2 Elseif = if not the first, do the second, or if not the second, do the third, etc. elseif ( conditional 3 ) do Command Group 3 else The "else" never has a conditional and is optional. do Command Group 4 end Loops k = first : step : last Loop index variable = first value : step size : last value Example of a loop in a script file: v1 = [ 0 : 5 : 25 ] ; % Define the vector v1 for i = 1 : length (v1) % The step size is 1 This loop calculates a new vector v2 from an existing vector v1. Note that the loop uses vector addressing. % Each pass in the loop v2(i) = v1(i) ^ 2 ; % calculates a new element % in the vector v2 end disp(v2) Common Functions sqrt(x) square root of x exp(x) 𝑒 𝑥 = exponential function abs(x) absolute value of x log(x) natural log of x log10(x) log base 10 of x factorial(x) factorial function [ x! ], where x is a positive integer sin(x) / cos(x) / tan(x) trig functions with angle in radians Name: Seat Number: __________ sind(x) / cosd(x) / tand(x) trig functions with angle in degrees round(x) Round to the nearest integer fix(x) Round toward zero ceil(x) Round toward infinity floor(x) Round toward negative infinity rem(x,y) Equals the remainder of x divided by y if rem(x,y) == 0 Conditional test that is true when x is a multiple of y sign(x) Signum function – returns [1 if x>0], [-1 if x<0], [0 if x=0] Name: Seat Number: __________ Practice Problems Problem 1: Work out Problem Use MATLAB to create a script file to accomplish the task described below. Save pdf files of both the script file and the plot. Write a script file that plots the step-input response of an RC circuit and an RLC circuit. Use a time interval 0 ≤ 𝑡 ≤ 10 𝑠𝑒𝑐𝑜𝑛𝑑𝑠 in increments of 0.01 seconds. The output “V” of each equation is in units of volts (V). Plot all three functions below for the time interval given. 𝑉𝑠𝑡𝑒𝑝 = 5 𝑉 𝑡 𝑉𝑅𝐶 (𝑡) = 𝑉𝑠𝑡𝑒𝑝 (1 − 𝑒 − ⁄𝜏 ) 𝑉𝑅𝐿𝐶 (𝑡) = 𝑉𝑠𝑡𝑒𝑝 [1 − 𝑒 −𝑡⁄𝜏 ∙ 𝑐𝑜𝑠(2𝜋𝑓𝑡)] 𝑓 is the natural frequency and 𝑓 = 0.5 𝐻𝑧 (0.5 cycles/sec) τ is the time constant, 𝜏 = 3 𝑠𝑒𝑐𝑜𝑛𝑑𝑠 Start your script file with disp(‘Your Name, seat #’) Name: Seat Number: __________ Problem 2: Work out Problem Use MATLAB to create a script file to accomplish the task described below. Save pdf files of both the script file and the plot. Write a script file that plots the three functions in the range 0 ≤ 𝑥 ≤ 50 in increments of 1. Units are not necessary for labeling the plot. 𝑦0 = 100 𝑦1 = 𝑥 2 − 50𝑥 + 400 𝑦2 = 𝑥3 − 3𝑥 2 + 59𝑥 − 229 25 Start your script file with disp(‘Your Name, seat #’) Name: Seat Number: __________ Problem 3: Work out Problem Use MATLAB to create a script file to accomplish the task described below. Save pdf files of the script file, the plot and the command window output. Write a script file that plots the function given and calculates the area under the function for a range 0 ≤ 𝑥 ≤ 𝜋 in increments of 0.0001. 𝑦 = sin 𝑥 𝑁 𝐴𝑟𝑒𝑎 𝑢𝑛𝑑𝑒𝑟 𝑡ℎ𝑒 𝑐𝑢𝑟𝑣𝑒 = ∑ 𝑦(𝑖)𝛥𝑥 𝑖=1 Where N = 31,416 or the length of 𝑥. Start your script file with disp(‘Your Name, seat #’) Name: Seat Number: __________ Problem 4: Work out Problem Use MATLAB to create a script file to accomplish the task described below. Save pdf files of the script file, the plot and the command window output. Write a script file that plots the function given and calculates the number of elements in the ranges listed below. Use a range for the plot and values of the function of 0 ≤ 𝑡 ≤ 20 seconds in increments of 0.001 s. Print the number of elements in each range with fprintf. 𝑦(𝑡) = 2.3 sin(2𝑡) ∙ 𝑒−𝑡⁄5 + 2 𝑟𝑎𝑛𝑔𝑒1 = 𝑡ℎ𝑒 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑒𝑙𝑒𝑚𝑒𝑛𝑡𝑠 𝑜𝑓 𝑦 𝑖𝑛 (0 ≤ 𝑦 ≤ 1) 𝑟𝑎𝑛𝑔𝑒2 = 𝑡ℎ𝑒 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑒𝑙𝑒𝑚𝑒𝑛𝑡𝑠 𝑜𝑓 𝑦 𝑖𝑛 (1 < 𝑦 ≤ 2) 𝑟𝑎𝑛𝑔𝑒3 = 𝑡ℎ𝑒 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑒𝑙𝑒𝑚𝑒𝑛𝑡𝑠 𝑜𝑓 𝑦 𝑖𝑛 (2 < 𝑦 ≤ 3) 𝑟𝑎𝑛𝑔𝑒4 = 𝑡ℎ𝑒 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑒𝑙𝑒𝑚𝑒𝑛𝑡𝑠 𝑜𝑓 𝑦 𝑖𝑛 (3 < 𝑦 ≤ 4) Start your script file with disp(‘Your Name, seat #’) Name: Seat Number: __________ Problem 5: Work out Problem Use MATLAB to create a script file to accomplish the task described below. Save pdf files of the script file only. Write a script file representing the code that the flow chart is outlining. The flow chart represents logic that will compute N! according to the equation 𝑁! = 1 ∗ 2 ∗ 3 ∗ … ∗ 𝑁. You do not have to run the script file with an input. Just print the script file as is. N_fact = 1 Start clc clear Display YOUR student information. for i = 2:N N_fact = N_fact*i Ask user to assign input number to “N” Display N_fact End i=i+1 Name: Seat Number: __________ Problem 6: Work out Problem Use MATLAB to create a script file to accomplish the task described below. Save pdf files of the script file only. Write a script file representing the code that the flow chart is outlining. The flow chart represents logic that will determine MATLAB’s computational speed running a “while” loop for 10 seconds. You do not have to run the script file with an input. Just print the script file as is. Start while toc ≤ 10 clc clear cycles = cycles + 1 Display YOUR student information. speed = cycles/ toc cycles = 0 Display computational speed to command window tic End Name: Seat Number: __________ 1) A plot is created by: 'plot(time,velocity,time,distance,time,acceleration)'. Write a single command to create a proper legend with labels DISTANCE, VELOCITY and ACCELERATION which corresponds to the generated plot. __________________________________________________________________________ 2) Write a single command to plot vector Distance as a function of vector Time. The plot produced should contain dashed red lines and no markers. __________________________________________________________________________ 3) Given that x=[1 2 3 4; 5 6 7 8; 9 10 11 12] has been assigned, what would be the result of y=x(2:3,[1 2 4])? __________________________________________________________________________ 4) Given a 10 by 3 matrix M, write a single command that extracts all members of the 3rd column of matrix M and assigns it to a vector called M_col_3 using the colon operator. __________________________________________________________________________ 5) The current flowing in the circuit is most nearly: a. 0.050 A b. 0.500 A c. 0.588 A d. None of the above. 5V 10 Ω 40 Ω 40 Ω 10 Ω 6) Given that x = [3 6 9] has been executed in the command window, what is the command necessary to evaluate the expression 2 x x 2 x 13 ? (You must use only the necessary dot operators) ___________________________________________________________________ Name: Seat Number: __________ 7) Given that x = [1:0.1:3] has been executed in the command window, what is the command necessary to evaluate the expression 2 cos2 (𝑥) tan(𝑥 3 ) /𝑒 𝑥 ? (You must use only the necessary dot operators) ___________________________________________________________________ 8) Given the function definition below, which variables are the input variables? function [z] = primenumber(x,y) ___________________________________________________________________ 9) Given the function definition below, what should the function file name be? function [z] = primenumber(x,y) ___________________________________________________________________ 10) Given the function definition below, can you use “x” as written within the main script file? function [z] = primenumber(x,y) ___________________________________________________________________