Engr 6 Matlab Programming What is Matlab Course
Engr 6: Matlab Programming �What is Matlab �Course Goals �Operations & Precedence �Variables �Error Types Vince Bertsch Analy Village: rm 627 (707) 527 -4621 vbertsch@santarosa. edu zoom. us/my/vbertsch �Functions �Commands �Course Logistics
What Does Matlab Do? � Numerical Computations � Visualization/Graphing � Programmable (interpreted) � Data Acquisition Toolbox � Graphical User Interfaces Calculator Excel C++, Java Logger Pro Lab View � Other Toolboxes for Engineering � Symbolic Equation � Simulation & Design � Signal Processing � Image Processing � Control Systems � Fuzzy Logic Mathematica, Maple
Course Goals �Computer programming skills �Computer as a tool for analysis, display, & interfacing �Collaboration for efficient learning & skill building �Matlab specific knowledge Goals may cause recurring problems due to narrowed focus and decreased intrinsic motivation. Use care when applying goals.
Scalar Operations & Precedence �( ) parentheses �^ exponents �/ * multiplication & division �+ - addition & subtraction Precedence Bingo Mark your 9 squares with numbers from 1 to 24 (no duplicates)
Variables �Case sensitive � 32 character max �Must start with a letter �No spaces or math symbols � *^-[. {; (%=@: . . . �Avoid command names & predefined constants � sin, exp, size, max, format, help � Na. N, pi, Inf, i, j, eps, ans, �= is assignment operator (not the math symbol) � >> Vin. Ht. Inch = 6*12 + 6 �Name returns the value � >> Vin. Ht. CM = 2. 54*Vin. Ht. Inch >> y+5=6 syntax error
Error Types �Syntax error � Computer gives red error message � Computer says, “I don’t understand. ” �Logical error � Result happens, but is wrong � User says, “That’s not what I meant. ” >> Vin. Ht. Inch = 6*10 + 6; >> Vin. Ht. CM = 2. 54*Vin. Htinch ? ? ? Undefined function or variable 'Vin. Htinch'.
Functions � exp(X) X input can be a number, a variable, or an expression � sin(X) Expects radians for the input � atan 2(Y, X) Two input function, separate the multiple inputs by a comma � [Value, Index] = min(Array) Two output function (needs brackets to left of assignment operator) The input is a new data type – an array Note the use of descriptive variable names with capitals >> doc function. Name Opens a documentation help page with information on the function
Commands & Shortcuts �format compact �doc atan 2 �lookfor degrees �up/down arrows �Cntl-c, Cntl-v �% �; eliminates extra line spaces help information on a function searches help for keywords to “get” previous lines of code cut and paste comment only (stop executing) suppress screen echo
� Canvas � Tech. Connect Zoom � Zoom to class � Cloud recordings � Zy. Book Assignments � Coding Assignments � Quizzes & Exams � Zoom Office Hours & Email � Syllabus/Schedule overview � Powerpoint PDFs Course Logistics
Assignments this Weekend �Zy. Books 1 Intro & Variables � Due Friday 11: 59 pm � Access via Canvas � Can submit partial work and continue � Collaboration encouraged �Coding Assignment 1 Variables � Due Sunday 11: 59 pm � Complete in Matlab � Cut & Paste to Word with labeling � Submit via Canvas (docx or pdf) � Collaboration encouraged – no copying of code or files
Key Programming Concepts � Descriptive Variable Names � Let Matlab do the Calculations � Comments for Units � Attention to Detail Ada Lovelace first computer programmer prophet of the computer age (Augusta King, nee Byron, Countess of Lovelace)
- Slides: 11