0% found this document useful (0 votes)
6 views3 pages

Matlab - Data Types

The document outlines various MATLAB functions for converting data types, such as cell arrays and structures, and provides a table of functions for determining the data type of a variable. It includes examples demonstrating how to use these functions with different data types, such as integers, floats, vectors, and character arrays. Additionally, it emphasizes the importance of understanding data types for effective programming in MATLAB.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Matlab - Data Types

The document outlines various MATLAB functions for converting data types, such as cell arrays and structures, and provides a table of functions for determining the data type of a variable. It includes examples demonstrating how to use these functions with different data types, such as integers, floats, vectors, and character arrays. Additionally, it emphasizes the importance of understanding data types for effective programming in MATLAB.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Page 4 of 6

cell2struct Convert cell array to structure array

cellstr Create cell array of strings from character array

mat2cell Convert array to cell array with potentially different sized cells

num2cell Convert array to cell array with consistently sized cells

struct2cell Convert structure to cell array

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified
expert to boost your career.

Determination of Data Types


MATLAB provides various functions for identifying data type of a variable.

Following table provides the functions for determining the data type of a variable −

Function Purpose

is Detect state

isa Determine if input is object of specified class

iscell Determine whether input is cell array

iscellstr Determine whether input is cell array of strings

ischar Determine whether item is character array

isfield Determine whether input is structure array field

isfloat Determine if input is floating-point array

ishghandle True for Handle Graphics object handles

isinteger Determine if input is integer array

isjava Determine if input is Java object

islogical Determine if input is logical array

isnumeric Determine if input is numeric array

isobject Determine if input is MATLAB object

isreal Check if input is real array

isscalar Determine whether input is scalar


Page 5 of 6

isstr Determine whether input is character array

isstruct Determine whether input is structure array

isvector Determine whether input is vector

class Determine class of object

validateattributes Check validity of array

whos List variables in workspace, with sizes and types

Example
Create a script file with the following code −

x = 3
Live Demo
isinteger(x)
isfloat(x)
isvector(x)
isscalar(x)
isnumeric(x)

x = 23.54
isinteger(x)
isfloat(x)
isvector(x)
isscalar(x)
isnumeric(x)

x = [1 2 3]
isinteger(x)
isfloat(x)
isvector(x)
isscalar(x)

x = 'Hello'
isinteger(x)
isfloat(x)
isvector(x)
isscalar(x)
isnumeric(x)

When you run the file, it produces the following result −


Page 6 of 6

x=3
ans = 0
ans = 1
ans = 1
ans = 1
ans = 1
x = 23.540
ans = 0
ans = 1
ans = 1
ans = 1
ans = 1
x=

1 2 3

ans = 0
ans = 1
ans = 1
ans = 0
x = Hello
ans = 0
ans = 0
ans = 1
ans = 0
ans = 0

You might also like