To check if two cell arrays have the same elements we can use the isequal
function. However, if the elements are not ordered in the same way, isequal
function will return false
.
In order to check if both cell arrays have the same elements regardless of their order we can use the sort
function.
Here is an example code:
main.m202 chars9 lines
In this example, we are using sort
function to sort both a
and b
cell arrays in ascending order. Then, we are using the isequal
function to check if they have the same elements. Since both cell arrays have the same elements, regardless of order, this code will output 'The cell arrays have the same elements'
.
gistlibby LogSnag