Use CELLFUN

%# find empty cells
emptyCells = cellfun(@isempty,a);
%# remove empty cells
a(emptyCells) = [];

Note: a(i)==[] won't work. If you want to know whether the the i-th cell is empty, you have to use curly brackets to access the content of the cell. Also, ==[] evaluates to empty, instead of true/false, so you should use the command isempty instead. In short: a(i)==[] should be rewritten as isempty(a{i}).

Answer from Jonas on Stack Overflow
🌐
MathWorks
mathworks.com › matlab › language fundamentals › data types › cell arrays
Create Cell Array - MATLAB & Simulink
Like all MATLAB® arrays, cell arrays are rectangular, with the same number of cells in each row. C is a 2-by-3 cell array. You also can use the {} operator to create an empty 0-by-0 cell array.
Discussions

How do I create an empty cell array of given dimensions?
How do I create an empty cell array of given... Learn more about matlab, cell arrays, cell array MATLAB More on mathworks.com
🌐 mathworks.com
2
2
June 12, 2018
Index Non-Empty Cells in Cell Array
Index Non-Empty Cells in Cell Array. Learn more about cell, array, index, indexing, nonempty, empty, cells, find, arrays More on mathworks.com
🌐 mathworks.com
2
3
June 28, 2012
How do i check for empty cells within a list
The find function then returns the indices of the empty cells. If you prefer a faster implementation, especially for large cell arrays, you can use the string form of cellfun: ... Sign in to comment. Sign in to answer this question. Find more on Workspace Variables and MAT Files in Help Center and File Exchange ... Find the treasures in MATLAB ... More on mathworks.com
🌐 mathworks.com
3
3
September 21, 2011
How to empty cell array?
Hi all How to empty cell array? I have a problem that every loop results overwrite the one before so I am trying to empty the cell array every loop so when it comes to successive loop the ... More on mathworks.com
🌐 mathworks.com
1
2
May 22, 2013
🌐
MathWorks
mathworks.com › matlab › language fundamentals › data types › cell arrays
cell - Cell array - MATLAB
Creating a cell array of empty matrices with the cell function is equivalent to assigning an empty matrix to the last index of a new cell array. For example, these two statements are equivalent: ... See Cell Array Limitations for Code Generation (MATLAB Coder).
Find elsewhere
🌐
MathWorks
mathworks.com › matlabcentral › answers › 468190-creating-an-empty-cell-in-an-array
creating an empty cell in an array - MATLAB Answers - MATLAB Central
June 21, 2019 - i have an array most made up of numbers and some are NaN i would like to make the NaN cells empty because i have a plotting function that doesnt accept NaN and when i assign it to 0 it affects the resulting graph, so im not really sure of how to make it blank with no numerical value ... https://www.mathworks.com/matlabcentral/answers/468190-creating-an-empty-cell-in-an-array#comment_716819
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1659810-creating-empty-cell-array-with-function
Creating empty cell array with function - MATLAB Answers - MATLAB Central
February 28, 2022 - Creating empty cell array with function. Learn more about cell, size, array, cell array, dynamics, function
🌐
GeeksforGeeks
geeksforgeeks.org › software engineering › cell-arrays-in-matlab
Cell Arrays in MATLAB - GeeksforGeeks
April 28, 2025 - 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. The cell() function creates an empty cell array of desired size.
🌐
Reddit
reddit.com › r/matlab › adding empty strings to a cell array
r/matlab on Reddit: Adding empty strings to a cell array
May 26, 2017 -
% create a simple array
a = {'a'} % prints a = 'a'
% try to add an empty string to it 3 different ways 
a = [a,''] % prints a = 'a', nothing gets appended
a{2} = '' % prints a = 'a' '', empty string gets appended
a{end+1} = '' % prints a = 'a' '' '', empty string gets appended

So the first way clearly doesn't work. Why not? Which is the "correct" way?

🌐
MathWorks
mathworks.com › matlabcentral › answers › 485978-add-empty-cell-inside-a-cell-array-considering-a-single-array
Add empty cell inside a cell array considering a single array - MATLAB Answers - MATLAB Central
October 17, 2019 - Surely, by now, with all the questions you've asked, you should be able to manipulate cell arrays yourself. ... https://www.mathworks.com/matlabcentral/answers/485978-add-empty-cell-inside-a-cell-array-considering-a-single-array#comment_757738
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1438779-how-to-remove-empty-cells-from-array
How to remove empty cells from array - MATLAB Answers - MATLAB Central
August 23, 2021 - Hi, I'm very new to matlab :) How can I remove the empty cells from the array in the attached image? I have tried data(~cellfun('isempty',data)), but this didn't work. Thank you for the help.
🌐
MathWorks
mathworks.com › matlab › programming › classes › construct and work with object arrays
empty - Create empty array of specified class - MATLAB
To initialize a nonempty array, use a function such as zeros or ones to fill the array with initial values. MATLAB does not have a null value, so all nonempty arrays must have values for all elements. You cannot use empty to create a 3-by-3 array, for example, because at least one dimension ...
🌐
TutorialsPoint
tutorialspoint.com › matlab › matlab_cell_arrays.htm
MATLAB - Cell Arrays
In this section will see an example that will show how you can convert a table to a cell array. Matlab comes with a function called table2cell() that helps to convert a table to a cell array.