Is there a better way to declare an empty, typed matrix in MATLAB?
- by Arthur Ward
Is there a way to "declare" a variable with a particular user-defined type in MATLAB? zeros() only works for built-in numeric types. The only solution I've come up with involves using repmat() to duplicate a dummy object zero times:
arr = repmat(myClass(), [1 0])
Without declaring variables this way, any code which does "arr(end+1) = myClass()" has to include a special case for the default empty matrix which is of type double.
Have I missed something a little more sensible?