Laboratory in Oceanography: Data and Methods Data Handling ...

嚜燉aboratory in Oceanography:

Data and Methods

Data Handling in Matlab

MAR550, Spring 2020

Miles A. Sundermeyer

Sundermeyer

MAR 550

Spring 2020

1

Data Handling Matlab

Overview of Matlab 每 Data Types

Fundamental Data Type

Many different types of data 每 cannot mix types within certain types of data arrays

? Numeric (floating point (single, double), int, uint, complex, logical)

? Characters & Strings

? Date / Time (behave like structures - Matlab works behind scenes on these)

? Catagorical Arrays

? Tables

? Timetables

? Structures

? Cell Arrays

? Function Handles

? Map Containers

? Time Series

Sundermeyer

MAR 550

Spring 2020

2

Data Handling Matlab

Overview of Matlab 每 Data Types

Examples of Different Data Types

% Create arrays of different data types - see what happens when combined

%% double and single

A = [sin(0:2*pi/9:2*pi)]

% double by default

A_single = single(A)

% create a single

AA = [A; A_single]

% combines to one data type

% reverts to the simpler data type

whos

%% int8

A_int8 = int8(A)

AA = [A; A_single; A_int8]

% create a signed integer(8) array

% combines to one data type

% reverts to the simpler data type

whos

Sundermeyer

MAR 550

Spring 2020

3

Data Handling Matlab

Overview of Matlab 每 Data Types

Examples of Different Data Types (cont*d)

%% logical

A_logical = logical(A)

% all non-zero real elements become 1,

% zeros become 0, nans not allowed

A_logical = A>0

% using logical operators

disp(A)

disp(A_logical)

% alternate way of displaying to workspace

AA = [A A_logical]

% show the two different logical arrays

% default here is to convert logical to double

whos

%% char

A_char = 'drifter.dat'

whos

Sundermeyer

MAR 550

Spring 2020

% array of characters to create a string

4

Data Handling Matlab

Overview of Matlab 每 Data Types

Examples of Different Data Types (cont*d)

%% cell arrays

Acell{1} = A

Acell{2} = A_single

Acell{3} = A_int8

Acell{4} = A_logical

Acell{5} = A_char

whos

% show indexing of cell array - note curly brackets, {}'s, as well as ()'s

Acell{1}(1:5)

A(1:5)

Sundermeyer

MAR 550

Spring 2020

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download