### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# ENGR 132 Exam 1 Study Guide ENGR132

Purdue

### View Full Document

## 61

## 0

## Popular in Intro to innovation and design 2

## Popular in Engineering and Tech

This 6 page Study Guide was uploaded by Sophia Planos on Monday February 15, 2016. The Study Guide belongs to ENGR132 at Purdue University taught by Tarmar Moore in Fall 2016. Since its upload, it has received 61 views. For similar materials see Intro to innovation and design 2 in Engineering and Tech at Purdue University.

## Similar to ENGR132 at Purdue

## Popular in Engineering and Tech

## Reviews for ENGR 132 Exam 1 Study Guide

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/15/16

ENGR 132 Exam Review Answers are bolded sometimes with italicized notes underneath. Some things were too hard to type in with the time constraint but were still in the review. These are tracking variables, matching histogram shape to cumulative distribution plot, finding 2 errors in code, writing equations from a chart, and finding r with a chart. Basic Commands 1. What do you type in matlab to calculate cos(30)? Cos(30*pi/180) 2. In matlab, what units do basic trig functions use? Radians 3. What do you type in Matlab to calculate √(7π/5)? Sqrt(7pi/5) or (7pi/5)^0.5 Vectors/Matrices 1. Write the matlab command to create a row vector A that starts at 2 and ends at 10 in increments of 1. A=2:10 or 2:1:10 2. Output of [1:2:10] 1,3,5,7,9, 3. Extract output (given below) from cars[1 2 3; 4 5 6; 7 8 9] 1 4 7 Cars(:,1) 4. Output of Amatrix is the same as same as cars[]. Find Amatrix(2,2:3). 5 6 5. Command to make Amatrix labeled as A but vertically instead of horizontally. A=[1 4 7, 2 5 8, 3 6 9] rd 6. Extract the 3 column of A and assign it as B. B= A(:,3) 7. Replace 4 and 7 from A with the 4th and 5th elements in C where C=[1 2; 3 4; 5 6] A(1,2:3) = C(4:5) 8. C=[0:3:15]. Do C=C.^2. What is C(4)? Would be 9, then square it =81 9. Write the command to raise an element of vector B to the second power. Assign it as D. D=B.^2 10. Given C=[1 2 3], multiply by B=[2 5 8] element by element B.*C 11. If C=[1 2 3] and B=[2 5 8] then B.*C= 2, 10 ,24 12. If B=[2 5 8], what is D if D=B^2? Error. You need a dot operator because dimensions don’t match. Scripts 1. You are given a variable Body_temp. Write a command to calculate its average and assign as an appropriate variable. Body_mean=mean(Body_temp) 2. If BodyT=[0 2 4 6 8], what is mean = mean(BodyT)? Mean =4, but no variables should be named after matlab functions 3. Write the command to load “normtemp.dat” and assign it as B ody_temp. Body_temp =load(‘normtemp.dat’) 4. If Maletemp=[ 1 2 3 4 5] and Time = [5 6 7 8], plot Maletemp vs. time. plot(time, maletemp) *Vectors are not the same length so this would give an error. Indicate command and list the error. 5. Using CoffeTemp and Time, use the ‘plot’ command to make a dotted green line with green square markers. plot(Time, CoffeTemp, ‘:gs’) (Note: The independent variable is always on the x axis.) 6. Find the 8 errors: This was given with 8 lines of code. All of the errors were: Misspelling; Capitalization (2); Loading wrong File type; Not commenting something out; No plot command when necessary; Wrong command used; Referenced a row instead of a column; According to the modules, the most common errors are related to: syntax; spelling; wrong data types used in low, matrix indexing, matrix math, inputs/outputs; directory path; variables defined in workspace; 7. How do you make a legend of a sine/cosine graph ? Legend(‘Sine’,’Cosine’) 8. Print “Today is Thursday”. fprintf(‘Today is Thursday’) 9. If you are given D=[2.356 5.365], print “The second element of D is equal to 5.4” . fprintf(‘The second element of D is equal to %.1f. ’,D(1.2)) (Note: 0.1 does 1 decimal place. F means float whereas s would be string) Histograms/Cumulative Distribution Plots 1. Histograms are made by using the _of each bin Center 2. Write the command that generates 6 bins of variable Body_temp. hist(Body_temp,6) 3. Estimated the number of bins in a histogram if there are 83 data points. √83=9.11 →9 4. In a histogram, the height of each bar represents the _ of the range. Frequency 5. What is the comman d used to make a histogram? hist(part_data,6) 6. How many number values fall in each bin? (Frequency?) [frequencyInBin,graphcenters] = hist(part_data, 6) (Note: two variables created in separate previous steps.) 7. Given a centers vector called newGraphCenters Force # of bins and bin centers (Note: Brittany and I had these two different lines as a description. I don’t actually know what this is solving.) Hist(part_data, newgraphcenters) Functions 1. Write User defined function named “motion” which has an input argument “time” and output “displacement” and “velocity” Function [displacement, velocity] = motion(time) 2. From the above function, how would you call the function using outputs ‘disp’ and ‘vel’? Assume t is defined. [disp, vel] = motion(t), same order, but use new variables 3. Velocity and time measurements are stored in vectors v and t. Create a user defined function called fcn that takes time and velocity as inputs coefficients ‘a’ as output, computes coefficient of the best fit line and assigns to ‘C oeff’ and displays the coefficients to the command window as: “B=x.xx. and a=y.yy.” function Coeff (1) = fcn(v,t) Coeff = polyfit (t, v,1) ; fprintf (‘b = %.2f, and a =%.2f.’,Coeff(2), Coeff(1)) Least Square Regression 1. Use least square regression method and the data above to set up the two simultaneous equations for tumor size as a function of time. 30a +5B = 25 220A + 30B =110 (Note: A chart was used to find the coefficients.) 2. Use the command to fit a regression line to these data points , and store the resulting slope and intercept in a vector called fitCoeff and use fitCoef to evaluate modeledTumorSiz e at each month. fitCoeff = polyfit(months, tumorsize,1) modeledTumorSize= polyval(fitcoefs, months) 3. Plot raw data using red squares, plot linear regression line with black solid line on same graph, print the slope. Plot(months, tumorsize, ‘rs’) Title() Ylabel Xlabel Hold on Plot(months, modeledtumorsize, ‘k’) Fprintf(‘The slope of the predicted line is: %.1f \n’,fitCoefs( 1) ’) 4. Find the coefficient of the regression line of Output_1=[6 -6] Y=6x+6 5. [Some question’s answer (Sorry I don’t know the question)]: Velocity_predicted = polyval (output_1,time) 6. How to get R^2 with a graph: SSE= ei 2 2 SST= [y-ybar] R =1-(SSE/SST) 7. Is an R of 0.93 good? Yes: 93% of variation hits the positive regression line.

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

#### "I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

#### "Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.