0

I have a matlab struct that has a sub-element such that when I run

class(foo.bar)

Gives the error:

Error using class
The CLASS function must be called from a class constructor.

When I just run foo.bar, ans gets set several times.

How can I find out which class bar belongs to?

1 Answer 1

2

I suppose you have a structure array as foo. Example:

>> foo = struct('a',{1 2})
foo = 
1x2 struct array with fields:
    a

>> foo.a
ans =
     1
ans =
     2

>> class(foo.a)
Error using class
The CLASS function must be called from a class constructor. 

>> class(foo(1).a)
ans =
double

Note that foo.a returns here what is called a comma-separated list.

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.