Cell Arrays in MATLAB Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In MATLAB, cell arrays are a type of arrays which stores elements of different data types and sizes in different cells, or one could say that cell arrays allow users to store heterogeneous data into a single array. For example, let us create a cell array which holds the name and age of a person. Example 1: Matlab % MATLAB Code for Cell arr = {"Harry", "Stark", 23} Output: This will create a cell array of 1x3: This was a simple example of cell arrays but, this is not a feasible way of creating them. So, we will now see better and efficient ways of creating and accessing the elements within. Creating Empty Cell Arrays:The cell() function creates an empty cell array of desired size. Its syntax is arr_name = cell (<size>); Let us see some examples, this will create a cell array of size x size dimensions. Example 2: Matlab % Creating Empty Cell Arrays Code arr = cell(3); Output: Example 3: Creating a cell array of size, size1 x size2 x ... x sizeN. Matlab % MATLAB Code for Creating Empty Cell Arrays arr = cell(3,2,3); Output: The resultant cell array would be of (3x2)x3 size. Accessing Elements of Cell Arrays:The elements of a cell array can be accessed by the same method of accessing ordinary arrays, by the indexing method. Let us see this with the help of an example. Example 4: Matlab % Accessing Elements of Cell Arrays in MATLAB arr = { ["Harry", "Stark"]; 2:9; linspace(1,2,5) }; % Accessing each element, one by one arr(1) arr(2) arr(3) Output: Comment More infoAdvertise with us Next Article Comments in MATLAB O owl0223 Follow Improve Article Tags : Software Engineering MATLAB Array-Programs Similar Reads Factorial in MATLAB MATLAB is a high-performance language that is used for matrix manipulation, performing technical computations, graph plottings, etc. It stands for Matrix Laboratory. In this article, we'll be calculating the factorial of a number n using MATLAB's built-in function 'factorial(number)'. Factorial:The 1 min read Create Array of Zeros in MATLAB MATLAB generally stores its variables in matrix forms, also in array and vector form. Sometimes, we often need a matrix(or array or vector) of zero(s) for some specific operations. We can create a matrix of zero(s) manually or with the help of the in-built function of MATLAB. The in-built function t 5 min read 2D Array Interpolation in MATLAB In this article, we are going to discuss "2D Array Interpolation" in MATLAB with the help of two linspace() and interp2() functions. Functions Usedlinspace( ) The linspace() function is used for the generation linearly spaced vector. Syntax: linspace(a, b) linspace(a, b, n) Here, linspace(a, b) is 4 min read Comments in MATLAB Comments are generic English sentences, mostly written in a program to explain what it does or what a piece of code is supposed to do. More specifically, information that programmer should be concerned with and it has nothing to do with the logic of the code. They are completely ignored by the compi 2 min read Anonymous Functions in MATLAB A block of code that is organized in such a way that is reusable for the entire program. Functions are used for reducing efforts made by writing code and making the program short, and easily understandable. There are different syntaxes for declaring a function in different programming languages. In 5 min read How to extract numbers from cell array in MATLAB? In this article, we are going to discuss the extraction of numbers from the cell array with the help of regexp(), str2double(), cat(), and isletter() functions. What is a Cell Array? A cell array is nothing but a data type having indexed data containers called cells, where each cell contains any typ 3 min read Like