Reputation: 2174
I want to create a three dimensional array of class objects in Matlab. I have defined my class using classdef
and now I want to use Matlab arrays to create arrays and access and modify the data I have created in the objects.
classdef MyClass
properties
MyPropertiy1
MyPropertiy2
end
methods
function a = func1(obj)
end
end
end
Now I want to have something like this:
mc = MyClass[2][3][5];
mc [1][2][2] = MyClass(param);
How can I do that?
Upvotes: 1
Views: 137
Reputation: 12214
As you've written it, except using MATLAB's indexing instead of Python's:
mc(2, 3, 5) = MyClass;
mc(1, 2, 2) = MyClass(param);
Note that, as written, your class can't accept any input arguments, so MyClass(param)
is going to throw an error.
Upvotes: 1