Is there a better way to declare an empty, typed matrix in MATLAB?

Posted by Arthur Ward on Stack Overflow See other posts from Stack Overflow or by Arthur Ward
Published on 2010-04-07T16:54:24Z Indexed on 2010/04/07 17:13 UTC
Read the original article Hit count: 191

Filed under:

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?

© Stack Overflow or respective owner

Related posts about matlab