Comparing Two Cell Arrays of Strings of Different Sizes in MATLAB Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report MATLAB is a high-performance language that is used for matrix manipulation, performing technical computations, graph plottings, etc. It stands for Matrix Laboratory. Cell Array: A cell Array in MATLAB is a data type that can store any type of data. Data is stored in cells in a cell array. It is initialized using { } i.e. curly braces. E.g. A = { 5, "gfg" , 7.2 } Accessing a Cell Array: To access a cell array we use curly braces and its index. Indexing starts with 1. E.g. A = { 5, "gfg" , 7.2 }Now A{1} will return 5, A{2} will return "gfg" and A{3} will return 7.2 Comparing Two Cell Arrays of Strings:ismember(a,b): It compares the 'a' and 'b' cell arrays and returns a logical array which has 0 and 1 of size same as of cell array 'a'. It returns 0 if the element in cell array 'a' is not present in cell array 'b'. If it is present it returns 1. setdiff(a,b): It compares the 'a' and 'b' cell arrays and returns an array that has elements from cell array 'a' that are not there in cell array 'b'. Syntax: ismember(a,b) setdiff(a,b) Example 1 : Matlab % MATLAB code A = { 'gfg' , 'geeks' , 'geeksforgeeks' }; B = {'gfg' , 'iam' , 'show' }; Output: ismember(A,B) , 1×3 logical array = [1, 0, 0] setdiff(A,B) , 1×2 cell array = {'geeks'} {'geeksforgeeks'}Explanation: 'gfg' is present in both the cell arrays hence the first element in the array is 1. The other two are 0 because 'geeks' and 'geeks for geeks' both are not present in the cell Array B. setdiff is returning cell array {'geeks'} {'geeksforgeeks'} because they are the elements from the cell Array A that are not present in cell Array B. Example 2: Matlab % Cell Array A A = { 'gfg' , 'geeks' , 'geeksforgeeks' } %Cell Array B B = {'gfg' , 'iam' , 'show' } % ismember function ismember(A,B) % setdiff function setdiff(A,B) Output: 1 0 0 {'geeks'} {'geeksforgeeks'}Input Example 3: Matlab % Cell Array A A = { 'program' , 'matlab' } %Cell Array B B = { 'matlab', 'programming' , 'gfg'} % ismember function ismember(A,B) % setdiff function setdiff(A,B) Output: 0 1 {'program'}inputoutput Comment More infoAdvertise with us Next Article Comparing Two Cell Arrays of Strings of Different Sizes in MATLAB A akashish__ Follow Improve Article Tags : Software Engineering Technical Scripter 2022 MATLAB Array-Programs Similar Reads Find Index of Cells Containing My String in MATLAB Cell Arrays in MATLAB are a type of array that store data in the form of cells. The benefit of using these cell arrays is that they can store data of different types as cells within a cell array only. In this article, we will see how to find a given string in a cell array. Firstly, we shall check wh 2 min read MATLAB Find Exact String in Cell Array Cell arrays in MATLAB store data of various data types as a cell. These cells could contain data of different types but belong to the same array. Now, this article is focused on finding an exact string in a cell array in MATLAB. This can be done easily by using a combination of two MATLAB functions, 2 min read How to find sum of elements of an array in MATLAB? This article will discuss the "Finding sum of elements of an array" in MATLAB that can be done using multiple approaches which are illustrated below. Â Using sum(A)Â This is used to return the sum of the elements of the array along the first array dimension whose size does not equal 1. It returns a ro 4 min read How to remove space in a string in MATLAB? In this article, we are going to discuss how to remove space from a string in MATLAB with the help of isspace(), find(), strrep(), and regexprep() functions. Using isspace() The isspace() function is used to identify elements that are ASCII white spaces. isspace('string') is used to find the white s 6 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 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 How to Find Index of Element in Array in MATLAB? In MATLAB, the arrays are used to represent the information and data. You can use indexing to access the elements of the array. Â In MATLAB the array indexing starts from 1. To find the index of the element in the array, you can use the find() function. Using the find() function you can find the indi 4 min read How to Declare and Initialize String Array in Excel VBA? A string array is an array where we can store only string values in the array, with the help of a string array, we can store more than one string value. We can declare the string array in many ways like declaring a static string array, declaring a variant size array of string using the Array functio 2 min read How to Find the Position of a Number in an Array in MATLAB? Finding the position of a number in an array, which can be done using the find() function. The find() function is used to find the indices and values of the specified nonzero elements. Syntaxfind(X) Parameters: This function accepts a parameter. X: This is the specified number whose position is goin 1 min read How to reverse a string in MATLAB? In this article, we are going to discuss the "Reversing of a string" in MATLAB which can be done in multiple approaches that are illustrated below: Method 1: Using Built-in Functions By using MATLAB built-in functions like reverse(), flip() and fliplr(). Built-in functions can be defined as - " The 3 min read Like