Presentation is loading. Please wait.

Presentation is loading. Please wait.

EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers.

Similar presentations


Presentation on theme: "EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers."— Presentation transcript:

1 EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers

2 Lecture Outline Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Introduction to MATLAB  The MATLAB Environment  Using MATLAB as a Calculator Slide 2 of 13

3 Introduction to MATLAB The MATLAB Environment Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Workspace: Currently defined variables Workspace: Currently defined variables Command Window: Main interface Command Window: Main interface Command History: Prior commands Command History: Prior commands Current Directory: A list of files & folders Current Directory: A list of files & folders Help Browser: Help on a variety of topics Help Browser: Help on a variety of topics Slide 3 of 13

4 Introduction to MATLAB The MATLAB Environment Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Assignment with semicolon  suppressed output!! Assignment without semicolon  output not supressed!! Command History: Prior commands Command History: Prior commands Slide 4 of 13

5 Introduction to MATLAB The MATLAB Environment – Saving to *.m files Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Saving commands to a file for reuse – “.m” files  Select “New Script” ( ) Run Icon: Select to run code Run Icon: Select to run code - Be sure to save files onto the “p:” drive. - Organization is very important!!! - Be sure to save files onto the “p:” drive. - Organization is very important!!! Slide 5 of 13

6 Introduction to MATLAB The MATLAB Environment – How to get “help” Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers If you know what you are looking for >> help sqrt If you not exactly sure what you are looking for >> lookfor sqr Can use the “Tab” key to autocomplete >> sqr Use the Help radio button (or >> doc sqrt) Slide 6 of 13

7 Introduction to MATLAB The MATLAB Env – Some important commands Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Stop the currently executing task >> Ctrl + C To clear the command window >> clc Remove variables from workspace >> clear all Slide 7 of 13

8 Introduction to MATLAB Using MATLAB as a Calculator Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers PrecedenceOperation FirstParentheses (innermost first) SecondExponentiation (from left to right) ThirdMultiplication and division (equal precedence, from left to right) FourthAddition and subtraction (equal precedence, from left to right.) Slide 8 of 13

9 Introduction to MATLAB Using MATLAB as a Calculator Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Which of the following is the correct result? MATLAB ExpressionResult #1Result #2 >> 8 + 3 * 52355>> (8 + 3) * 52355 >> 8 / 4 * 2 14 >> 8 /(4*2) 1 4 >> 3 * 4 ^ 2 + 5 53149 >> 27 ^ 1 / 393>> 27 ^(1/3)93 Slide 9 of 13

10 Introduction to MATLAB Valid Variable Names Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Valid Names for MATLAB Variables  MUST begin with a letter (a-z or A-Z).  Followed by any combination of letters, numbers (0-9), and the underscore (_) characters. o CHARACTERS such as &,^,%,@,… are not allowed  MATLAB keywords cannot be variables (e.g., for, if, end,…) o For a complete list, run the “iskeyword” command. o Valid variable names: “Area_51”, “x0”, o Invalid variable names: “_Area_51”, “0x”, “end”, “n!”,  MATLAB variables are case-sensitive o Cost, cost and coSt are all different variable names Use meaningful variable names!! Slide 10 of 13

11 Introduction to MATLAB Using MATLAB as a Calculator Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Slide 11 of 13

12 Introduction to MATLAB Using MATLAB as a Calculator - Graphing Calculator Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers Slide 12 of 13

13 Next Lecture Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers MATLAB basics  Variables and arrays Slide 13 of 13


Download ppt "EGR 115 Introduction to Computing for Engineers Introduction to MATLAB Friday 29 August 2014 EGR 115 Introduction to Computing for Engineers."

Similar presentations


Ads by Google