Review:
Exam 2- MATLAB
Supplemental Instruction
IowaStateUniversity / Leader: / Becca
Course: / ChE 160
Instructor: / Heinen & Haman
Date: / 10/09/2016

Resources

  • Appendix E, Flowcharts in Eide textbook
  • YouTube is a great resource for helping you find your way around MATLAB
  • Fitzle LLC has professors from Vanderbilt University breaking MATLAB down
  • MATLAB Help (question mark in upper right hand corner or typing “help” in command window”. You can search for whatever you want to find help files on your topic!

Study strategies

  • Really understand the basics and go from there
  • Look at the SI worksheets posted
  • Redraw graphs and figures
  • Rewrite notes
  • Reword ideas and principles
  • Write out steps to problem solving
  • Talk about notes and concepts with a friend
  • Make your own example problems
  • Write a reference sheet with all study information to review right before

Notes from Becca

  • Read through Exam 2 information on Blackboard
  • You should be able to finish the entire exam in 50 min
  • Strategize—start with the easy problems first to knock them out or hard problems first
  • If you don’t know, skip it and come back
  • Show your work! Partial credit is better than no credit

PRACTICE EXAM (Note: adapted from Dr. Heinen’s practice exam format, and this practice exam is longer than what the actual exam would be!)

State the value of the variable that results from each of the MATLAB commands. (Do you understand the logic of loops? How can you organize the values after each loop interation?)

T = 8;T =

while T <= 87

T = T*2 ;

end

z(1,1) = 40; z =

for count = 2:5

z(1,count) = z(1,count-1) / 2;

end

x = 2;answer =

if x < 10 & x > 4

answer = 55;

elseif x<10 & x < 4

answer = 34;

else

answer = 1;

end

Plot the following data and fit a curve (trendline) to model the data. (Break this part down into manageable pieces! You learned how to plot data and fit a curve last unit)

time [s] = 0, 5, 10, 15, 20, 25

Q [J] = 1501, 684, 299, 81, 25, 9.3

  1. Use colon notation to assign time data to a column vector. (What is the order for the colon notation values?)
  1. Enter heat Q data into a column vector called Q. (What are different ways to create a column vector?)
  1. Graph the data using blue-filled circles with red outlines- once using rectangular axes and one with semilog axes. Display both stacked vertically using subplot with rectangular on top plot and semilog on bottom plot. Add title and axis labels. (What are the notations for that marker indicator? How do you plot using subplot? How do you add a title and labels?)
  1. Fit Q vs. time data using polyfit(). Assume that the data produces a straight line on the semilog plot. (What does polyfit do? In the big picture of creating a trendline/curve to fit the data, how does polyfit fit in?)
  1. Use linspace and polyval() to crease 500 fitted x and fitted y values corresponding to the fit from question 4. (In the big picture, what does linspace do for us? How do we use polyval? Don’t forget your semicolon after linspace!!)
  1. Add the fitted values from question 5 to the semilog plot created in question 3. Use a straight, green line. (How do you add something to an old graph? How do you create a line?)

Use a nested for loop to create a personalized [5x3] matrix.(What built-in MATLAB function would you use to prompt a user to add their own values?)

Write a nested for loop to create the following matrix: (Why would you use a nested for loop to generate this matrix?)

Write MATLAB code to solve the linear algebraic equations below:(What is the general set-up for matrix algebra with MATLAB?)

2x – 4y + 6z = 22

3x +11y +8z = 65

7x + 5y – 9z = 17

The temperature outside is 70 °F, a beautiful fall day. Write a single conditional statement that displays whether the temperature is too cold, too hot, or just right. If the temperature is too cold or hot, calculate how many degrees it should change to reach the ideal 70 °F, and display the temperature change within a sentence. (You may combine the sentences if you wish). (What would be a good loop for this type of problem? How will you set it up?)

A 7.1 m^3 cylindrical tank rated to a pressure of 15.7*10^5 Pa contains 1500 moles of gas. Use a while loop to calculate the maximum temperature that the gas in the tank can reach before exceeding the pressure rating. Begin at 273 K and work in 5 K increments. R = 8.314 Pa m^3/mol K. Use fprintf function to display maximum temperature and pressure. Use comments to label units.(How do you add a comment? What are some key pieces to the while loop? What should be inside and outside of the loop?)

KNOW HOW TO CALCULATE THE SUM OF NUMBERS AND THE FACTORIAL!

ALSO KNOW THE COMPONENTS OF SUBPLOT!

Don’t forget to brush up on areas, surface areas, and volumes of shapes and log and natural log functions.

What should you spend more time studying?

Are there any study strategies that have worked well for you? Keep doing it 