5 min read

Basic (and Geo-) Data Type and Structure in Matlab

Data and Functions are the most important two parties of every programming language (for data science or processing). It just like Nome and Verb in every natural language. Data describe the information of something and Functions define the action that how to deal the Data.

In this blog we will talk about the basic data type in Matlab. And my points maybe can give you some ideas to renew the basic data type and structure, but the truly important thing is that, you need read the official documents always.

(Atomic) Data Type

official documents: Data Types in Matlab

In this site Matlab has definite the type of atomic data and the struct of the combination of amount of atomic data together as Data Type. The reason actually is very clear, whether atomic or amount of atomic data are represent with one name. But I think with the divided mode we can recognize them more clearly.

Atomic Data means a single, indivisible unit of data.

There are four basic (Atomic) Data Type in Matlab:

  • Numeric: include signed and unsigned integers, and single-precision and double-precision floating-point numbers (from Matlab).
  • Characters and Strings (from Matlab):
    • character is just only one character;
    • string array is text with several characters.
  • Dates and Time (from Matlab): The date and time data types datetime, duration, and calendarDuration support efficient computations, comparisons, and formatted display of dates and times.
  • Categorical(from Matlab): store data with values from a finite set of discrete categories.

Data Structure

official documents: Data Types in Matlab

In this part discuss we how Matlab organize the data structure, that contain a mount of atomic data.

Common Structure

The moooost important Structure in Matlab is array, in the same time it’s also very so special that Matlab think it not belong to one class (Type or Structure): MATLAB is an abbreviation for “matrix laboratory.” While other programming languages mostly work with numbers one at a time, MATLAB® is designed to operate primarily on whole matrices and arrays; A matrix is a two-dimensional array often used for linear algebra (from Matlab).

Array is allllways contain a mount of one type of (Atomic) Data, so we can also see the class of Array of one Type as the Type of his basic Data, without any misunderstand. So, with the function class() you can’t get the results with 'array' or 'matrix'.

Expect the Array and Matrix, there are some other basic Structs:

  • table: suitable for column-oriented or tabular data that is often stored as columns in a text file or in a spreadsheet. Tables consist of rows and column-oriented variables. Each variable in a table can have a different data type and a different size with the one restriction that each variable must have the same number of rows (from Matlab).
  • timetable: a type of table that associates a time with each row(from Matlab).
  • cell array: a data type with indexed data containers called cells, where each cell can contain any type of data.

Three is a simple Illustration: every color block is one class

Illustration of Matlab Dataclasse

For Array it can only contain some atomic data, for Table, Structure and cell it can contain every Class in Matlab. In my opinion we can understand the Cell-array as a folder in our computer system, one folder can not only contain other any data bust also a other folder.

Geo-Data

In generally we can divide the geological data into two types: Raster and Vector (Shape). We can read and plot the both data, but we can’t almost analyse the Geo-Data in Matlab, the supply of Geo-Data now is still very weakness and the using is also unfriendly 😞😞.

Raster Data

The Raster data in Matlab is also divided in two Geographic Rasters, Planar Map Rasters and World File Matrices. The third one seems not so common, I have also don’t meet some data that need use this type. So, we just talk abou the first two types. With Geographic Rasters we can easily understand that its CRS (coordinate reference system) is in lon-lat system, but the CRS of Planar Map Rasters is mapped th X-Y.

The both raster data are saved in two data in Matlab, one of them store the truly Data in Matrix, the other store the CRS information in:

  • GeographicCellsReference for Geographic Rasters
  • MapCellsReference for Planar Map Rasters

Vector (Shape) Data

The Vector data in Matlab is also consist of two parties:

  • Geometry in Geographic Data Structures
  • Attributes in N-by-1 attribute structure array stored

Subset and Substructure

In Matlab we can use (call) a data with it’s name, but we will not always need the whole data than sometimes need we only a part of them. So, we need the operate to get only the part.

If now we define the two concepts:

  • Subset: a part of one data and the class of this part is not changed in the same level
  • Substructure: a part of one data and the class of this part is the next level class

I need to note that: the same class means not only same class from function class() but also same level. Some like table of table of string and table of string have the same class table, the second data belong to Substructure but not Subset.

There are three operators that can get the part of data: Dot ., Parentheses () and Curly brackets {}.

  • Dot .: got the Substructure, can be used in 'table', 'struct' and 'cell'
  • Curly brackets {}: got the Substructure, can be used in 'table', 'struct' and 'cell'
  • Parentheses (): got the Subset, can be used in all data structure (not atomic data) 'array', 'table', 'struct' and 'cell'

We need always to knew that, what kind of data we have, what kind of data we will get from one function, so that when we can want to get the part of our data, we make no mistake.

The end.

I hope my opinion about the data type and structure in Matlab is useful for you.