Presentation is loading. Please wait.

Presentation is loading. Please wait.

THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014 www.clarkson.edu/class/honorsmatlab.

Similar presentations


Presentation on theme: "THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014 www.clarkson.edu/class/honorsmatlab."— Presentation transcript:

1 THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014 www.clarkson.edu/class/honorsmatlab

2 Who are we?  Jim: Junior Aeronautical – Mechanical Engineer  elmerjc@clarkson.edu  Joe: Senior Mechanical Engineer  quinzijn@clarkson.edu

3 Quote of the Week “This is a full time campus. Believe me, there’s nothing exciting going on downtown.” Prof. Cetinkaya

4 Before We Begin:  Any Questions? Comments? Concerns?  Feel free to contact Jim or Joe We can set up small group tutoring or one-on-one You can email us with questions or concerns We are here for you! Even if it isn't about MATLAB

5 Homework  Create and submit a PDF file using the publish tool in Matlab  Feel free to work in groups!  Do NOT have identical code  Questionable integrity will be examined  This is your FIRST & FINAL WARNING

6 The MATLAB Interface Open MATLAB: Start  All Programs  MATLAB

7 MATLAB Interface [cont.] Double Click on variable and it will open this “excel” like editor

8 The Editor  The Editor is a supped up ‘notepad’  It is where you will be spending most of your time.  It allows you to write your code, save it, open it up again, run it as well as many more advance options.  Open it from:  New Script  The “New” icon has options to create other different things like functions and GUIs

9 The Editor [cont.] Line Number Save & Run script Where MATLAB will try to point out possible errors with your code, and offer suggestions! How nice!

10 MATLAB FUNDAMENTALS The 'Supped-Up Graphing Calculator' – In the command window: 25 + 5 > Result: ans = 30 > – So… what does this mean? You can use the command window like a scratch-pad or calculator, using familiar math symbols. Addition: a + b Multiplication: a * b Subtraction: a - b Division: a / b Exponentiation: a^b

11 MATLAB FUNDAMENTALS  Order of Operations  Parentheses left to right  Exponents left to right  Division AND Multiplication left to right  Addition AND Subtraction left to right

12 MATLAB FUNDAMENTALS  Creating Variables / Arrays  The assignment operator= > = >;  Variable names must begin with a letter and can only contain letters, numbers, and the underscore.  Examples:  x = 1;  y = [1 2 3 4];  z = [1 0 0; 0 1 0; 0 0 1];

13 MATLAB FUNDAMENTALS  Variables and Arrays  Variables store values (numbers and text)  Scalar  Vector  Array (Matrix)

14 MATLAB FUNDAMENTALS  Mathematical Operations with arrays  Use.*./.^ when using operation on an array or vector  Array Indexing  Indexing an array is to specify a specific location to extract its value and or to perform an operation.  Arrays are indexed as follows: A(i,j)  Refers to the i th row and j th column. i j

15 Elementary MATLAB Commands FunctionSyntax (What to type in)Example Display disp(‘Hello’) disp(x) Hello 5 Trig Functions sin(pi/2)1 Square Root sqrt(16)4 Remainder rem(15,6)3 Size d=[1 2 3;4 5 6] size(d) [2 3] Clear clear(Clears all variables) Clear Screen clc(Clears Screen)

16 Numerical Display  See page 39 in your texts MATLAB CommandDisplayExample format short 4 decimal points 3.1416 format long 14 decimal points 3.14159265358979 format short e 4 decimal points 3.1416e+000 format long e 14 decimal digits 3.14159164358979 3e+000 format bank 2 decimal digits 3.14 format + +, -, blank + format rat Fractional form 355/113

17 Help command  Help function: Universal!  Solves many problems created by Jim and Joe!!  ‘help’ is a great place to start when totally lost  ‘help _______’ insert a function in the blank ie cos, solve, plot, etc…  Mathworks website has an explanation for every function in matlab

18 Publishing  Go to the Publish tab  Click the drop box below the Publish icon and select edit publishing options  Change the output format to PDF  Click the Publish icon

19 Questions?  Questions?  HW # 1  Due by 5:00 PM, Wednesday September 3 rd, to cuhonorsmatlab@gmail.com cuhonorsmatlab@gmail.com  You are to submit: PDF file of your published code Make sure to use comments % Question 2.2 Problems: 2.2, 2.3, 2.4

20 Homework Example  Go to Problem 2.3 in your books  Step 1: Create variables for numbers 1-9  Step 2: Evaluate each equation using only the variables you created  Step 3: Create a 3x3 array containing numbers 1-9  Step 4: Evaluate each equation using only references to the array you created


Download ppt "THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014 www.clarkson.edu/class/honorsmatlab."

Similar presentations


Ads by Google