1

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.