Title | Matlab Note 1-1 |
---|---|
Author | wen xie |
Course | Introduction to Programming |
Institution | 國立清華大學 |
Pages | 3 |
File Size | 208.4 KB |
File Type | |
Total Downloads | 94 |
Total Views | 146 |
MATLAB...
Parentheses:括弧 Tables, cell arrays, and structures are MATLAB data types that store heterogeneous data. A table in MATLAB looks like a table you might see in a report or spreadsheet. Each column is named and has a single data type. Cell arrays are also rectangular but are more flexible than tables, because each element can hold any data type of any size. Cell arrays do not have named columns and must be indexed numerically. Structures are good when you have non-tabular, named data that you want to collect together in a single variable.
Organizing Workspace Variables in a Table When several variables in your workspace hold data about the same observations, you can use the table function to collect this information into a table.
tbl = table(var1,var2, 'VariableNames',{'Thought1','OnSecondThought'})
You can join tables together with the join function to match corresponding rows using key variables. >> newTbl = join(tbl1,tbl2,"Keys",["Var1" "Var2"])
Extracting Portions of a Table
Extracting from a Single Column Using Dot Notation variableData = tableName.VariableName
Extracting from Multiple Columns Using Curly Braces variableData = tableName{rowIndices,colIndices}
Use logical vectors to check idx = fleet.Type == "compact" smallCars = fleet{idx,["Make" "Model"]} The vartype function allows you to select all columns of a specific data type. For instance, T{:,vartype("categorical")} extracts data from all of the categorical columns and outputs a categorical array.
Cell arrays can be used to combine related variables of different sizes. 用{ , ; } ,分隔一列中的東西 ;換列 Categories function
lower function...