BE 1500 Notes for Week 1
BE 1500 Notes for Week 1 BE1500
Popular in Intro to Programming
verified elite notetaker
Popular in Engineering and Tech
This 10 page Class Notes was uploaded by Neha Bhagirath on Saturday May 14, 2016. The Class Notes belongs to BE1500 at Wayne State University taught by Tonya Whitehead in Spring 2016. Since its upload, it has received 11 views. For similar materials see Intro to Programming in Engineering and Tech at Wayne State University.
Reviews for BE 1500 Notes for Week 1
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 05/14/16
DAY 1 Coding Vocab Syntax: The set of rules that defines the combinations of symbols that are considered to be a correctly structured document or fragment in that language (set of rules that govern how things are done) Command: An instruction to a computer or device to perform a specific task Variable: A storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quantity of information (a name we associate with some sort of data so MATLAB knows that, for example, a=15, and it’ll know every time we put “a”, it is 15. It is storing things we need in a variable.) Comment: A line of text (command) that will not be executed but it’s there to help you understand more. Add at the end and put a % sign. Function: A special type of code that performs a particular operation, usually requires input and returns an output Input: Required program or data that is received by a program or function and used by it Output: What you get back. Data or info returned after a program or function is completed Program: A set of code to complete multiple tasks, may include calls to functions Excel Vocab Workbook: T he file type created by excel Sheet: Individual “tab” in the workbook Cell: Individual location in the sheet where data is stored Formula: Calculations done within a cell MATLAB Vocab Logicals: True/False (ex. Does a=b) Assigning values to variables directly: Ex. A = 4; B = 9; Assigning values to variables through other variables: Ex. C = A + B; C=13 Notes: Names can be anything except reserved words (get, format, pi), has to start with a letter, no spaces You can only use the variables in your workspace! More examples: format compact Error Messages you may get Undefined function or variable “e” it can’t find the variable Error using format you need something AFTER the word format Unexpected MATLAB operator you may be trying to type 2x or 2a but you need the multiplication sign in between Expressions or statement is incomplete/incorrect ex. Missing brackets Error using * (Inner matrix dimensions must agree) Evenly Space Row Vector > the 1 : 0.5 : 3 means that it is at 1 and goes 0.5 up each time and ends at 3 Lin means linear function Log means logarithmic function V,V2,V3,V4...Etc are just different variables CAPITALS AND LOWERCASE ARE DIFFERENT b=mod(a,m) put numbers for a and m and it will calculate b (which is the remainder after division) M=m(9) means in the matrix m, the 9th entry you count down column 1, then down column 2, etc, to count the entries Linspace means linear points and logspace means log points, it is written like, for example: linspace(1,5,4) means from 1 to 5, with 4 points. Same for log, but the points will be logarithmically spaced If you have 1:3:9 you would have 1 4 7 because it is from 1 to 9 in increments of 3, and 1 4 7 is the highest because then it would be 10 If you have 3:1:10 it is not possible so you get an empty matrix error DAY 2 To use e, put exp(⅔) or whatever exponent you want no need for the “^” a=1:2:9 means 1 to 9 with increments of 2 if you want the third row, first column of a matrix > V=m(or whatever variable defines your matrix)(row,column) Have to use built in matlab functions if she asks (aka NOT writing out the whole matrix) Before comma is rows, then after comma is columns: ex. M([1 3], 2:3) means 1 st and 3rd rows of 2nd and 3rd columns All columns in row 1 is V=m(1,:) Three ways to make a matrix: using the colon operator, linspace, or other builtin MATLAB functions Other Matrix commands: fliplr means flip the matrix from left to right flipud means flip from up to down (bottom to top) rot90 means rotate matrix 90 degrees matrix addition and subtraction > matrices must match rows and columns (it’s always element by element) matrix multiplication/division/powers > the inner dimensions must match > 2x3 times 3x2 (the 3 and 3 match.) Do (A.*B) > C*D is not the same as C.*D. The period in front of the multiplication sign, or the division, or the power sign, tells MATLAB that it is element by element. (You can multiply straight out and do row times columns, or you can do element by element by using a period) Operations with Two matrices: A=[1 3; 10 12] and B=[11 9; 8 7] You can do A/B, A\B, B\A, A\B, A*B, B*A, A.*B, B.*A, etc You cannot do matrix multiplication #13 in the homework day 2every time you are plugging a vector into an equation, and using a power, use element by element because you have a row times row times row times row cannot do that without transposing. Therefore, do element by element