Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.

Similar presentations


Presentation on theme: "Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1."— Presentation transcript:

1 Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1

2 Fundamental components of MATLAB MATLAB stands for Matrix Laboratory MATLAB = a calculator + a lot more A computing system that accepts one instruction at a time. Instructions MUST conform to a specific syntax and vocabulary. A large library of modules that provide high-level capabilities for processing data. A collection of toolboxes, providing graphical capabilities. A graphical user interface (GUI) to allow you to assemble your own professional looking software. 2

3 Different Windows of MATLAB Opening MATLAB in a lab: most computer on campus will have a direct shortcut on the desktop If not, use Ernie (directions online) 3 Double Click to bring up the MATLAB Interface

4 Running MATLAB via Citrix

5 5 Frame #1 “The Command Window” Frame #2 “Current Directory” Frame #3 “Workspace” Frame #4 “Command History” “Your Calculator Screen” You can do exactly as on your calculator: add, subtract, divide, multiple, use parentheses to override the order of operations… Later on, you will realize you can do a LOT more in this frame. This frame shows the files (excel, text, MATLAB files) that can immediately be used. It will show the variables that have been created. It will show all the commands executed previously.

6 General Setup 6

7 A new window: the Editor 7

8 8

9 9 "DOCK IT"

10 Final common setup! 10

11 How it will work… 11 1. Type your statements here 2. Run your statements (or hit F5) 3. See your results here (Modify your statements, repeat cycle)

12 1. Basic Data Manipulation New vocabulary: Variables Assignment Storing values in the computer It is assumed that these terms are understood: Input Output Programmer User

13 1. Basic Data Manipulation Starting MATLAB on every machine usually leads to the prompt symbols >> in the command window 13

14 1. Basic Data Manipulation A variable is a name given for a memory location “Assigning a value to a variable” means to place a value in the memory location associated with the variable name MATLAB usually shows what the variables are - in the Command Window, but also in the Workspace.

15 1. Basic Data Manipulation How about solving equations? Normal algebra ≠ programming Assume the following mathematic equation: z = x + y In algebra: when z is 10 and y is 7, what is x equal to? 15 z = x + y 10 = x + 7  Solve for x, obtain _____ Look at MATLAB:

16 1. Basic Data Manipulation 16 Assign values to variables z and y

17 1. Basic Data Manipulation 17 Assign values to variables z and y Once x is on the left side, and all known variables (z and y) are on the right, MATLAB executes the command.

18 1. Basic Data Manipulation In MATLAB, all the known variables must be on the right side of the equal sign before executing the command. At any time, only one variable can be on the left. 18 Assign values to variables z and y Once x is on the left side, and all known variables (z and y) are on the right, MATLAB executes the command.

19 2. Basic Data Understanding How exactly is the data stored in the memory?  binary (i.e. machine) language: 0 and 1’s How is the number 2 represented then? Remember that the symbol we see is NOT the value represented by it. For example: what number do these represent? V|||| 19  5

20 2.1 The Binary System As shown on the previous slide, a number can be represented using different symbols used for different bases. In fact, any set of symbols can be created to represent numbers. In the “binary” system (base 2), there are only two symbols: 0 and 1 With just these two symbols, a computer can represent any number we want!

21 2.1 The Binary System Base 10Base 2 0 0 2 1 1 2 2 10 2 3 11 2 4100 2 5101 2 6110 2

22 2.1 The Binary System How does 10 represent a 2 ? 22

23 2.2. The ASCII table 23 Group the 0’s and 1’s to represent what you want Done automatically!

24 2.2. The ASCII table For example: The symbol 2 in decimal is represented using the sequence 0000 0010 in binary. 24

25 2.2. The ASCII table Even for characters… 25

26 The limit between calculator and programming software Although MATLAB looks like a calculator, data can be stored in ASCII format as well. Be careful: MATLAB will execute mathematical operations on characters. What does this mean? For example, in the command window, Do It Yourself (2.3) radius = 49 radius + 1 radius = ‘radius of a circle’ radius + 1 26 What is the expected outcome? What is the un-expected outcome?

27 3. Creating Good Variables This last example should make you realize the importance of good variable names: those that describe their content. Do not name a variable radius when it will contain a name, or a sentence, prefer title_radius in the example above. In the long term, it will save you time debugging (fixing errors!) 27

28 3. RULES To create a variable in MATLAB, simply assign it a value. When coming up with a name, follow these RULES: It cannot contain spaces: Use the underscore, or capitalizeTheFirstLetterOfAdditionalWord It cannot start with a digit. However, it can have digits in the rest of it. It cannot contain any special characters (other than the underscore of course!) It should not be any keywords MATLAB knows, or It should not be the filename of any saved files 28

29 3. Good HABITS Good Programming Habits applied in EGR115 It must represent its content NO one letter long variables, except for loop counters: v, t, p, x Keep it short, it will avoid typos later on If you can, include units IN MATLAB: lower case i (Square root of -1) and j already have values. Other letters are better choices. 29


Download ppt "Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1."

Similar presentations


Ads by Google