220 likes | 244 Views
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.
E N D
The MATLAB EnvironmentVariablesBasic CommandsHelp 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 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
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
Double Click on variable and it will open this “excel” like editor MATLAB Interface [cont.]
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
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.
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 • 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 ith row and jth column. j i
Numerical Display • See page 39 in your texts
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
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? • Questions? • HW # 1 • Due by 5:00 PM, Wednesday September 3rd, 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 3x3 array containing numbers 1-9 • Step 4: Evaluate each equation using only references to the array you created