Chapter 2 Notes
Chapter 2 Notes COMP 1200 - 002
Popular in MATLAB
Popular in Computer Information Systems
This 5 page Class Notes was uploaded by Nichole Kirby on Wednesday September 23, 2015. The Class Notes belongs to COMP 1200 - 002 at Auburn University taught by Jacqueline Holliday Hundley in Fall 2015. Since its upload, it has received 97 views. For similar materials see MATLAB in Computer Information Systems at Auburn University.
Reviews for Chapter 2 Notes
I'm really struggling in class and this study guide was freaking crucial. Really needed help, and Nichole delivered. Shoutout Nichole, I won't forget!
Report this Material
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: 09/23/15
MatLab Notes Chapter 1 MatLab Matrix Laboratory that excels at computations involving matrices 0 Performs the same functions as a scientific calculator Chapter 2 MatLab Windows Command window it allows you to save the values you calculate but not the commands used to generate those values 0 To save these command you will have to use the editor window which would create a Mfile Command History records the commands you issued in the command window 0 To clear the command history type in clc gt this action clears the command window but leaves data in the command history window intact Workspace Window keeps track of the variables you have defined as you execute commands in the command window 0 Variables allows you to assign a value A3 I Should be read as A is assigned a value of 3 0 Use the variables in a subsequent calculations 0 You can have your workspace window display more information about your variable by right clicking on the bar with column labels You can view the variables name value size bytes and class 0 clear gt this commandaction deletes all of the saved variables it only works with the workspace window 0 whos gt command returns and finds out which variables have been defined after the clear command Current Folder Window lists all the files in the active directory 0 MatLab either accesses files or saves information by using the current folder unless told differently Document Window stores values in the variable that are displayed in the spreadsheet format Graphics Windows launches when requesting a graph 0 Must list your xvalues and yvalues and to create the graph you must use the plot command Plot X930 Edit Window window allows to type and save a series of commands without executing them 0 Several ways to open and editing window either from the file menu or with the new file icon 0 Can also open the edit window by typing in the edit command which will open the Toolstrip Command Window and Editing Window are powerful tools for solving engineering problems Variables gt How do computers store information In a variable gt What is a variable Variables are locations in memory that can store a value Regular variables can hold one and only value The value can be changed but when changed the original value is lost forever Naming Variables 339 Must start with a letter az AZ 339 Other character you can use az AZ 09 0 v Can be no more than 63 characters 339 Upper and Lowercase 339 No Blanks To check if your variable name is allowed use the isvarname command 0 Names are case sensitive can be treated differently depending on whether it is in capitals or lowercase text Instructure s Rules for Naming Variables gt Be Descriptive Choose a name that represents the information gt Camel backing or underscore Ex angonthlySalary or avgMonthlySalary gt Constant variables are NOT changed All capital letter ex MAXAVERAGE 100 Comments The sign identifies comments Would need one on each line or use and for a multi line comment 0 MATLAB will not execute any code on a commented line Saving your work gtgt diary yourFileNametxt gtgtdiary off If no file name given puts in gtgtdiary The file is saved in the current directory Be sure it s the one you want to use Matrices in MatLab Matrix basic data type used in MATLAB group of number arranged Cl257 Cl2 57 Vector a matrix composed of a single row or a single column Example B1 2 5 or B2 2 5 Bl25 B22 5 Scalar singlevalued matrix Example A 5 A 5 0 When working with Matrices always make sure all the rows must have the same number or columns to do operations Array Operations Explicit List a list identifying each member of a matrix Spaced Matrices Example b 15 b 1 2 3 4 5 Command puts the vector as evenly spaced square brackets are optional Example c l25 C 1 3 5 0 If you want to calculate the spacing between elements then use the linespace command Example d linespace 1 10 3 d 1 55 10 Initial value the nal value how many total values returns the vector with 3 values evenly spaced between 1 and 10 0 You can also create logarithmically spaced vectors with logspace command Example e logspace 1 3 3 e 10 100 1000 First elements are in the vector is 101 and the last element is 103 0 We can add and subtract matrices normally Example a 1 2 3 b 6 7 8 a b ans 7911 0 However multiplication and division are a little different We need a different operator to indicate elementbyelement multiplication The operator is called dot multiplication Example ab ans 6 14 24 When you multiply a scaler times and array you may use either operator or 0 You also have to do the similar command for exponentiation A and elementbyelement division Example aquot2 ans 1 4 9 Example ba ans 6 72 83 When you divide with a scalar by and array you still need the J syntax because the l means taking the matrix inverse to MATLAB Scientific Notation Example 6022e23 Values in scientific notation are designated with an e between the decimal number and the exponent 0 Display Format no matter what you choose MATLAB uses doubleprecision oatingpoint numbers in its calculations which result in approximately 16 decimal digits of precision Example A 51 A 5100 Or if A 511 A 5 l 1000 MATLAB allows you to specify other formats that show additional digits MATLAB Commands format short 4 decimal digits 31416 format long l4 decimal digits 314159265358979 format short e 4 decimal digits scientific notation 3 l4l6e000 format long e l4 decimal digits scientific notation 3141592653589793e000 format bank 2 decimal digits only real values are displayed 3 14 format short eng 4 decimal digits engineering notation 3 l4l6e000 format long eng l4 decimal digits engineering notation 3141592653589793e000 format blank format rat fractional form 355 133 format short g MATLAB selects the best format 31416 format long g MATLAB selects the best format 314159265358979 Special Characters forms matrices used in statements to group operations
Are you sure you want to buy this material for
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'