EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials Matlab Tutorial Data Types in MATLAB
Secondary Sidebar
Matlab Tutorial
  • Basic
    • MATLAB Area Under Curve
    • MATLAB not equal
    • MATLAB max
    • MATLAB exist
    • MATLAB Table
    • MATLAB regression
    • MATLAB Lists
    • MATLAB quantile
    • MATLAB Round
    • MATLAB readtable
    • MATLAB disp
    • MATLAB Standard Deviation
    • MATLAB quadprog
    • MATLAB Transpose
    • Introduction to MATLAB
    • Advantages of MATLAB
    • MATLAB Features
    • Taylor Series MATLAB
    • MATLAB Z Transform
    • fsolve in MATLAB
    • MATLAB QR
    • Career in MATLAB
    • Uses Of MATLAB
    • MATLAB Free
    • How to Install MATLAB
    • How to Use MATLAB?
    • MATLAB Version
    • MATLAB Compiler
    • MATLAB Commands
    • MATLAB Block Comment
    • MATLAB? sprintf
    • MATLAB fprintf
    • Data Types in MATLAB
    • MATLAB Integral
    • MATLAB Double Integral
    • MATLAB boolean
    • MATLAB vpa
    • MATLAB Object
    • MATLAB Annotation
    • MATLAB Variables
    • MATLAB Global Variables
    • MATLAB Operators
    • MATLAB Logical Operators
    • MATLAB nan
    • MATLAB Patch
    • MATLAB AND Operator
    • MATLAB OR Operator
    • Vectors in MATLAB
    • What is Simulink in MATLAB
    • MATLAB Interpolation
    • MATLAB Imread
    • fscanf MATLAB
    • Euler Method MATLAB
    • Root Locus MATLAB
    • MATLAB return
    • Bode Plot MATLAB
    • Nargin MATLAB
    • MATLAB Matrix Inverse
    • MATLAB String to Number
    • MATLAB string
    • MATLAB ColorBar
    • MATLAB Surfc
    • MATLAB Concatenate
    • NUMEL MATLAB
    • MATLAB? File Extension
    • MATLAB File
    • MATLAB Smooth
    • MATLAB ones
    • Exponential in MATLAB
    • MATLAB ksdensity
    • MATLAB log
    • MATLAB Append
    • MATLAB hold on
    • MATLAB Magnitude of Vector
    • Heatmap in MATLAB
    • MATLAB xticks
    • MATLAB randn
  • Control Statements
    • IF-Else Statement in MATLAB
    • If Statement in MATLAB
    • Loops in MATLAB
    • For Loop in MATLAB
    • While Loop in MATLAB
    • do while loop in MATLAB
    • Nested Loop in MATLAB
    • Switch Statement in MATLAB
    • Break in MATLAB
  • Functions
    • MATLAB Functions
    • MATLAB user defined function
    • Calling Functions in MATLAB
    • Transfer Functions in MATLAB
    • Anonymous Functions in MATLAB
    • Inline Functions in MATLAB
    • Bessel Functions in MATLAB
    • Mean Function in MATLAB
    • Find Function MATLAB
    • Filter Function in MATLAB
    • IIR Filter MATLAB
    • Piecewise Function in MATLAB
    • Sum Function in MATLAB
    • Simulink MATLAB Function
    • MATLAB Create Function
    • MATLAB Inverse Function
    • MATLAB Count
    • Step Function MATLAB
    • MATLAB limit
    • Fminsearch in MATLAB
    • Covariance in MATLAB
    • Summation in MATLAB
    • Linear Fit MATLAB
    • MATLAB?linear regression
    • MATLAB Derivative
    • MATLAB Derivative of Function
    • MATLAB Comet()
    • Fzero MATLAB
    • xlabel MATLAB
    • Matplotlib Legend
    • Matplotlib Subplots
    • Plot graph MATLAB
    • MATLAB Format
    • MATLAB plot title
    • Multiple Plots in MATLAB
    • MATLAB Indexing
    • Ceil MATLAB
    • Curve Fitting MATLAB
    • MATLAB trapz()
    • MATLAB Normalize
    • MATLAB diff
    • MATLAB sym()
    • MATLAB Syms
    • Absolute Value MATLAB
    • MATLAB Exponential
    • Kalman Filter MATLAB
    • Low Pass Filter MATLAB
    • Bandpass Filter MATLAB
    • MATLAB Unique
    • Trapezoidal Rule MATLAB
    • MATLAB Root Finding
    • MATLAB stem()
    • MATLAB loglog()
    • MATLAB Autocorrelation
    • MATLAB Sort
    • Simplify MATLAB
    • Cumsum MATLAB
    • Eval Function MATLAB
    • Polyval MATLAB
    • MATLAB Colon
    • MATLAB Eigenvalues
    • MATLAB fit
    • Delta Function MATLAB
    • MATLAB Remainder
    • Differentiation in MATLAB
    • Permute MATLAB
    • isempty MATLAB
    • MATLAB text()
    • MATLAB Display Text
    • Varargin in MATLAB
    • MATLAB gca
    • MATLAB fill()
    • MATLAB pcolor()
    • MATLAB min
    • MATLAB xcorr
    • MATLAB? color codes
    • Semilogy MATLAB
    • MATLAB? eye
    • feval MATLAB
    • num2str in MATLAB
    • MATLAB Images
    • MATLAB Image? Segmentation
    • Imagesc MATLAB
    • MATLAB Image Processing
    • MATLAB Image Resize
    • MATLAB Flag
    • MATLAB fopen
    • Strcmp MATLAB
    • MATLAB fwrite
    • MATLAB fft()
    • MATLAB zeros()
    • MATLAB textread
    • Arctan MATLAB
    • MATLAB Scripts
    • Butterworth filter MATLAB
    • MATLAB Findpeaks
    • MATLAB find Index
    • MATLAB Cell
    • MATLAB Unit Step Function
    • MATLAB Backslash
    • MATLAB Mod
    • Size Function in MATLAB
    • Secant MATLAB
  • Matrix
    • Matrix in MATLAB
    • 3D Matrix in MATLAB
    • Transpose Matrix MATLAB
    • Sparse Matrix in MATLAB
    • Matrix Multiplication in MATLAB
    • Identity Matrix in MATLAB
    • MATLAB?writematrix
  • Advanced
    • MATLAB Class
    • Arrays in MATLAB
    • Matlab find value in array
    • MATLAB Grader
    • Power Spectral Density MATLAB
    • Matlab Textscan
    • String Array in MATLAB
    • MATLAB Random Numbers
    • Matlab Dot
    • MATLAB 2D Array
    • MATLAB? zero padding
    • MATLAB sort matrix
    • MATLAB Plot Function
    • 2D Plots in MATLAB
    • 3D Plots in MATLAB
    • MATLAB Fread
    • Spectrogram MATLAB
    • MATLAB Average
    • MATLAB exponent
    • MATLAB not enough input arguments
    • MATLAB comment
    • MATLAB zpk
    • Scatter Plots in MATLAB
    • MATLAB 3d scatter plot
    • Bar Graph in MATLAB
    • Bar Plot MATLAB
    • Log Plot MATLAB
    • Polar Plot in MATLAB
    • Surface Plot in MATLAB
    • MATLAB Plot Circle
    • Boxplot in MATLAB
    • MATLAB Plot Multiple Lines
    • Linspace MATLAB
    • Histogram in MATLAB
    • Plot Vector MATLAB
    • MATLAB Legend
    • MATLAB Plot Legend
    • MATLAB ezplots
    • Column Vector MATLAB
    • MATLAB Plot Marker
    • MATLAB LineWidth
    • MATLAB Line Style
    • Contour plot in MATLAB
    • MATLAB Sine Wave
    • Reshape in MATLAB
    • Natural Log in MATLAB
    • Random Number Generator in MATLAB
    • Complex Numbers in MATLAB
    • MATLAB Figure
    • Heatmap in MATLAB
    • MATLAB Technical Computing
    • Colors in MATLAB
    • Colormap in MATLAB
    • MATLAB Plot Colors
    • MATLAB fplot()
    • MATLAB Stacked Bar
    • MATLAB sphere()
    • MATLAB cylinder()
    • MATLAB mesh()
    • Pie Chart in MATLAB
    • MATLAB Gradient
    • Grid on MATLAB
    • Repmat in MATLAB
    • dlmread in MATLAB
    • Meshgrid in MATLAB
    • MATLAB Struct
    • MATLAB Cross Product
    • MATLAB colorbar Label
    • MATLAB Save Variable
    • MATLAB Saveas
    • MATLAB Cell Array
    • Polynomial in MATLAB
    • ismember MATLAB
    • Heaviside MATLAB
    • MATLAB rref
    • MATLAB polyfit()
    • MATLAB xlim
    • MATLAB Variance
    • Optimset MATLAB
    • Quiver MATLAB
    • Newton Raphson MATLAB
    • Mat2cell MATLAB
    • Magnitude MATLAB
    • format long MATLAB
    • Dot Product MATLAB
    • Jacobian MATLAB
    • What is Matlab?
    • Convolution MATLAB
    • Moving Average MATLAB
    • Fourier Series MATLAB
    • Gaussian Fit MATLAB
    • Bisection Method MATLAB
    • Laplace Transform MATLAB
    • Fourier Transform MATLAB
    • Signal Processing MATLAB
    • MATLAB Forms
    • Complex Conjugate MATLAB
    • MATLAB Write to File
    • uigetfile MATLAB
    • MATLAB Toolbox
    • MATLAB Errorbar
    • MATLAB Index Exceeds Matrix Dimensions
    • Nyquist MATLAB
    • Impulse Response MATLAB
    • xlsread MATLAB
    • MATLAB xlswrite
    • Matplotlib Scatter
    • MATLAB Import Data
    • MATLAB Export Data
    • MATLAB Read CSV
  • Programs
    • Square Root in MATLAB
    • Square Wave MATLAB
    • Squeeze MATLAB
    • Factorial in MATLAB
    • Cell to String MATLAB
  • Interview Questions
    • MATLAB Interview Questions

Related Courses

MATLAB Certification Course

R Programming Course

All in One Data Science Courses

Data Types in MATLAB

By Priya PedamkarPriya Pedamkar

Data Types in MATLAB

Overview of Data Types in MATLAB

Data Types in MATLAB are the supported data formats that are used for computation. MATLAB is a popular mathematical and statistical data analysis tool that has a wide range of features for computation. The various types of data type MATLAB supporting are numeric types, characters, strings, date and time, categorical arrays, tables, timetables, Structures, Cell Arrays, Functional Handlers, Map Containers, Time series, Data type Identification, Data type conversion. Each of the data types accepts and processes a certain type of data format through the variables. MATLAB provides the functionalities to convert one data type to another compatible data type using the conversion functions

Data Types in MATLAB

Following are the Data Types:-

  • Numeric Types
  • Characters and Strings
  • Date and Time
  • Categorical Arrays
  • Tables
  • Timetables
  • Structures
  • Cell Arrays
  • Functional Handles
  • Map Containers
  • Time Series
  • Data Type Identification
  • Data Type Conversion

Let’s see the significance of the individual Data Types in MATLAB in details-

  1. Numeric Types: Under this type comes Integer and floating-point or fraction data
  2. Characters and Strings: Text are represented in character arrays and string arrays
  3. Dates and Time: This contains arrays of date and time values which can be again shown in many different formats such as DD/MM/YYYY or MM/DD/YY etc.
  4. Categorical Arrays: Under this comes arrays of qualitative data such as a list with values from a finite set of discrete sampled or data of the type non-numeric.
  5. Tables: Arrays are represented here in a tabular form whose named columns may contain different types such as numeric, categorical, etc.
  6. Timetables: Time-stamped data such as DD/MM/YYYY/HR/MIN/SEC in tabular form.
  7. Structures: Most versatile as well as complex, this type contains arrays with named fields that contain varying types and sizes.
  8. Cell Arrays: This again is a data type where an array can contain data of variable types and sizes.
  9. Function Handles: Such data types allow variables to call a function indirectly.
  10. Map Containers: Similar to the dictionary in many languages, such data types have objects with keys where the key is indexed to values, where keys need not be integers.
  11. Time Series: Time series data has a specific type where data vectors are sampled over the time period.
  12. Data Type Identification: Such data types help us determine the data type of any variable.
  13. Data Type Conversion: Using such types, we can convert between many data types such as numeric arrays, cell arrays, character arrays, structures, function handles, and tables, etc.

Now let’s look into each type with more details

Data Types Definition
Int8 This is called 8 bits signed integer
Uint8 This is 8 bits unsigned integer
Int16 16 bits signed integer
Uint16 16 bits unsigned integer
Int32 32 bits signed integer
Uint32 32 bits unsigned integer
Int64 64 bits signed integer
Uint64 64 bits unsigned integer
Single This is called single-precision numeric data
Double This is double-precision numeric data
logical The logical value of 0 or 1 represents true or false
char Character data such as alphabets
Cell array an array of indexed cells where each cell is capable of storing an array of the same or different dimensions and different data type
structure This is more like a C structure where each structure has a named field which is capable of storing an array of different size or dimension and different data types
Function handle This acts as a pointer to a function
User classes Such data types represent objects which are constructed from a user-defined class
Java classes Such types represent objects which are constructed from a Java class.

Examples

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Below is the example

Code:

strg = 'Hello MATLAB!'
n = 234510
dbl = double(n)
unt = uint32(7891.50)
rrn = 15678.92347
cons = int32(rrn)

Output: –

strg = Hello MATLAB!n = 234510dbl = 234510unt = 7901rrn = 15678.9cons = 15679

  • In the above example, strng is string data type, n is numeric data type, dbl is double data type, unt is 32 bit unsigned integer, rrn is fractional data which is converted to int 32 integer and stored as cons.

Conversion of Data Types in MATLAB

Function Purpose
char This function converts from to character array (string)
int2str This function converts from integer data to the string
mat2str This function converts from a matrix to string
num2str This function converts from number to string
str2double This function converts from string to double-precision value
str2num This function converts from string to number
native2unicode This function converts from numeric bytes to Unicode characters
unicode2native This function converts from Unicode characters to numeric bytes
base2dec This function converts from base N number string to decimal number
bin2dec This function converts from binary number string to decimal number
dec2base This function converts from decimal to base N number in string
dec2bin This function converts from decimal to binary number in string
dec2hex This function converts from decimal to hexadecimal number in string
hex2dec This function converts from hexadecimal number string to decimal number
hex2num This function converts from hexadecimal number string to double-precision number
num2hex This function converts from singles and doubles to IEEE hexadecimal strings
cell2mat This function converts from cell array to numeric array
cell2struct This function converts from cell array to structure array
cellstr This function creates a cell array of strings from a character array
mat2cell This function converts from array to cell array with potentially different sized cells
num2cell This function converts from array to cell array with consistently sized cells
struct2cell This function converts from structure to cell array

Conclusion

  • From the above discussion and example, we got a deep look into the various data types of MATLAB programming language. Each of these data types is very important and MATLAB users need to deeply understand the property and usages of each of these types to write efficient MATLAB programs that are fast, optimized for performance, and scalable for future needs.
  • As a beginner, users are advised to practice a lot of these syntaxes so that they can understand their usages and relative advantages and disadvantages. Such coding practice is important to have great control over any language and to be able to write efficient MATLAB codes.

Recommended Articles

This has been a guide to Data Types in MATLAB. Here we discuss the introduction, list, and conversions of data types in MATLAB with an example. You can also go through our other suggested articles to learn more –

  1. Matlab Operators
  2. Getting Started with Applications of Matlab Commands
  3. Career in MATLAB
  4. MATLAB Interview Questions
  5. Matlab Compiler | Applications of Matlab Compiler
Popular Course in this category
MATLAB Training (3 Courses, 1 Project)
  3 Online Courses |  1 Hands-on Project |  8+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

All in One Data Science Bundle(360+ Courses, 50+ projects)
Python TutorialMachine LearningAWSArtificial Intelligence
TableauR ProgrammingPowerBIDeep Learning
Price
View Courses
360+ Online Courses | 50+ projects | 1500+ Hours | Verifiable Certificates | Lifetime Access
4.7 (86,650 ratings)
R Programming Training (13 Courses, 20+ Projects)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
1 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

SPSS, Data visualization with Python, Matplotlib Library, Seaborn Package

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more