This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Mech 221: Computer Pre-Lab Assignments To help you succeed in this course, there will be pre-lab assignments for every computer lab. The goals of the pre-labs are to reinforce concepts taught in class that will be used in the labs and to introduce any new MATLAB commands that will be used in the upcoming lab. By doing the pre-labs, you will make yourself ready to do the labs in the allotted time. Four out of ten of the marks for a lab are based on the pre-lab questions. Solutions to pre-lab assignments should be handed in to the TA at the beginning of each lab. Mech 221: Computer Pre-Lab 1 Hand in the solutions to the two questions in the pre-lab at the beginning of the lab. Pre-Lab Learning Objectives : After completing this pre-lab assignment, you should be able to: recognize the correct syntax of and describe the output of some MAT- LAB commands used to create and access parts of a vector, to perform numerical integration, and to create plots; determine an adequate number of points to get sufficient accuracy from a numerical integration method; interpret, modify, and write MATLAB code to implement algorithms for numerical integration. Point of Clarification : As discussed in the lecture notes, when a problem needs to be solved using N intervals, this is done with N + 1 function values at evenly spaced points at the ends of these intervals. 1 MATLAB commands to know for the lab Commands to create a vector: linspace(a,b,N) This command will generate a linearly spaced vector with N evenly spaced components, or points, between the values a and b , inclusive. For example, >> x = linspace(0,2,5) will create the row vector: x = 0.5000 1.0000 1.5000 2.0000 As mentioned in the Point of Clarification above, these 5 points corre- spond to 4 subintervals of equal length within the interval [0, 2]. a:b This command will generate a row vector of values from a to b , inclu- sive, with distance between successive points equal to 1. For example, >> x = 1:4 will create the row vector with entries 1 2 3 4 . a:dx:b This command will generate a vector of values from a to b , inclusive, with distance between successive points dx . For example, >> x = 0:0.25:1 will create the row vector: x = 0.2500 0.5000 0.7500 1.0000 This command is useful if you want to create a vector of values with a...
View Full Document
This note was uploaded on 10/26/2010 for the course ENGINEERIN MECH221 taught by Professor Wetton during the Spring '10 term at The University of British Columbia.
- Spring '10