1

I have an object in Matlab created from a third party toolbox. Within the object is a 3x65 double array. If I type the name of the object in the Matlab console, it lists all the contents, and specifically says this 3x65 array is a double. All I want to do is to extract this array into a separate Matlab array. But when I do something like:

x = object.ArrayIWant

I get the error "Access to an object's fields is only permitted within its methods." If I try the following:

x = get(object,'ArrayIWant)

I get the error "Conversion to double from 'toolboxfunction' is not possible. How do get access to this array?!

4
  • Try this: val = get(object.ArrayIWant,'Value'). Type "object" and see if you could see its fields. Commented Mar 13, 2014 at 22:18
  • Does the class provide access methods? Could you write your own if it doesn't? Commented Mar 13, 2014 at 22:19
  • Divakar: same as the first error when I do that. Commented Mar 13, 2014 at 22:24
  • Floris: I don't think so? But I don't really have an understanding of programming enough to tell, to be honest. Commented Mar 13, 2014 at 22:25

1 Answer 1

1

Look for "Get" methods in the class:

methods(object)

or

methods className

Say it says there is a method called GetArrayIWant, then you'd do:

x = object.GetArrayIWant();
Sign up to request clarification or add additional context in comments.

2 Comments

So when I do methods(object), I get a list of functions (is that what we're calling methods?). If I run these functions on the object, they just return another object that I can't access. I'm not sure how to use the functions to retrieve a specific field in the object.
@user1566200 Yes, those are functions that belong to the class, and which can access the attributes of the class (i.e. the array you want). What "get" methods are there and can you give a whos of the output of the likely candidates?

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.