THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP

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

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

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

Before We Begin: Any Questions? Comments? Concerns? Feel We free to contact Jim or Joe 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

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

The MATLAB Interface Open MATLAB: Start All Programs MATLAB
![MATLAB Interface [cont. ] Double Click on variable and it will open this “excel” MATLAB Interface [cont. ] Double Click on variable and it will open this “excel”](http://slidetodoc.com/presentation_image_h2/97fc3583af606e0a88ed2cf18028dc12/image-7.jpg)
MATLAB Interface [cont. ] Double Click on variable and it will open this “excel” like 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
![The Editor [cont. ] Save & Run script Line Number Where MATLAB will try The Editor [cont. ] Save & Run script Line Number Where MATLAB will try](http://slidetodoc.com/presentation_image_h2/97fc3583af606e0a88ed2cf18028dc12/image-9.jpg)
The Editor [cont. ] Save & Run script Line Number Where MATLAB will try to point out possible errors with your code, and offer suggestions! How nice!

MATLAB FUNDAMENTALS • The 'Supped-Up Graphing Calculator' – In the command window: 25 + 5 <<enter>> • Result: ans = 30 – <<line spaces removed>> 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

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

MATLAB FUNDAMENTALS Creating Variables / Arrays The assignment operator <<variable_name>> = = <<data to be stored>>; 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];

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

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

Elementary MATLAB Commands Function Syntax (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)

Numerical Display See page 39 in your texts MATLAB Command Display Example format short 4 decimal points 3. 1416 format long 14 decimal points 3. 14159265358979 format short e 4 decimal points 3. 1416 e+000 format long e 14 decimal digits 3. 14159164358979 3 e+000 format bank 2 decimal digits 3. 14 format + +, -, blank + format rat Fractional form 355/113

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

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

Questions? HW # 1 Due by 5: 00 PM, Wednesday September 3 rd, to 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

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 3 x 3 array containing numbers 1 -9 Step 4: Evaluate each equation using only references to the array you created
- Slides: 20