Here are two code snippets illustrating my problem:
classdef SomeClass properties foo; bar; endend
and in another file:
classdef SomeOtherClass properties %Array of SomeClass objects.
someClassArray; end methods function obj = SomeOtherClass(n) %Initialize the array, as n can be large.
obj.someClassArray(n,1) = SomeClass(); end end end
When initializing an object of the second class, Matlab assusmes the someClassArray property is a double, and gives an error:
The following error occurred converting from SomeClass to double:Conversion to double from SomeClass is not possible.Error in SomeOtherClass (line 10) obj.someClassArray(n,1) = SomeClass();
How do I get around this?
Best Answer