Q&A
Ask and answer questions to make information more available to wider audiences.
Jameson Blow @blowjameson   22, Aug 2023 12:00 AM
a Regular array vs a Cell array
When should I use a Regular array vs a Cell array?
answers 3
 
Answer 1
Drake Boot @bootdrake85   31, Aug 2023 03:25 PM
And prefer Regular Array when:

All of the elements have the same type.
You are updating the whole array in one shot - like mathematical operations.
You want to have type safety.
You will not change the data type of the array in the future.
You are working with mathematical matrices.
You are working with objects that have no inheritance.
 
Answer 2
Drake Boot @bootdrake85   31, Aug 2023 03:25 PM
It's better to use Cell Array when:

You have different types in your array.
You are not sure whether in the future you might extend it to another type.
You are working with objects that have an inheritance pattern.
You are working with an array of strings - almost on any occasion it is preferable to char(n,m).
You have a large array, and you often update a single element in a function.
You are working with function handles.

 
Answer 3
Drake Boot @bootdrake85   31, Aug 2023 03:24 PM
In short,
a Cell Array is a heterogeneous container,
a Regular Array is homogeneous.
This means that in a regular array all of the elements are of the same type, whereas in a cell array, they can be different.