Chapter 2:MATLAB Basics Part 1:Variables and Arrays Part 2:Multidimensional Arrays ▣Part3:Subarrays Part 4:Special Values Part 5:Displaying Output Data Part 6:Scalar and Array Operations Part 7:Hierarchy of Operations Part 8:Built-in Functions 细月济大学 TONGJI UNIVERSITY
Chapter 2: MATLAB Basics Part 1: Variables and Arrays Part 2: Multidimensional Arrays Part 3: Subarrays Part 4: Special Values Part 5: Displaying Output Data Part 6: Scalar and Array Operations Part 7: Hierarchy of Operations Part 8: Built-in Functions
MATLAB Basics(1/40) Variables and Arrays Variable is a name given to a reserved location in memory 。class code=l1l; number of students =65; name ="Tongji University'; radius 5; area pi radius 2; @日济大学 TONGJI UNIVERSITY
➢ Variable is a name given to a reserved location in memory • class_code = 111; • number_of_students = 65; • name = ‘Tongji University’; • radius = 5; • area = pi * radius^2; MATLAB Basics(1/40) Variables and Arrays
MATLAB Basics(2/40) Variables and Arrays Use meaningful names for variables MATLAB variable names .must begin with a letter can contain any combination of letters,numbers and underscore ( must be unique in the first 31 characters >MATLAB is case sensitive: ·“name',Name”and“NAME”are considered different variables Never use a variable with the same name as a MATLAB command CPHAW Naming convention:use lowercase letters 月停大学 TONGJI UNIVERSITY
MATLAB Basics(2/40) Variables and Arrays ➢ Use meaningful names for variables ➢ MATLAB variable names • must begin with a letter • can contain any combination of letters, numbers and underscore (_) • must be unique in the first 31 characters ➢ MATLAB is case sensitive: • “name”, “Name” and “NAME” are considered different variables ➢ Never use a variable with the same name as a MATLAB command ➢ Naming convention: use lowercase letters
MATLAB Basics(3/40) Variables and Arrays >The fundamental unit of data is array colurgealar vector row 3 1 -3 11 15 -2 3 21 1 0 13 matrix @日济大学 TONGJI UNIVERSITY
MATLAB Basics(3/40) Variables and Arrays ➢ The fundamental unit of data is array 3 scalar 1 -3 11 vector 15 -2 3 21 -4 1 0 13 matrix row column
MATLAB Basics(4/40) Variables and Arrays >Three common ways to initialize a variable in the MATLAB Assign data to the variable in an assignment statement Input data into the variable from the keyboard ·Read data from a file CDHAW 同你大学 TONGJI UNIVERSITY
MATLAB Basics(4/40) Variables and Arrays ➢ Three common ways to initialize a variable in the MATLAB • Assign data to the variable in an assignment statement • Input data into the variable from the keyboard • Read data from a file