rolf
rolf

Reputation: 41

show structure of handles while programming in matlab

Is it possible to see the structure of my struct variables while I'm programming?

I'm programming in matlab gui. I store my variables in the struct variable "handles". When I want to know how i structured the variable I have to run my programm and stop it while running to look up the structure of my variables.

Is it possible, that if I type in my code "handles" that I see a list of all containing variables (and other struct variables)?

(I know that from Visual Studio)

Upvotes: 2

Views: 54

Answers (1)

plesiv
plesiv

Reputation: 7028

Matlab Structure type is a dynamic type - fields/members of the variables of this type can change during run-time. There is no trivial way to know before the execution of a program all the fields/members that certain Structure instance (variable) will contain.

I assum you worked with some statically-typed language in Visual Studio (C#, C++ etc.). Members of variables in those languages are known at compile-time - that's the reason you can have useful tools providing you with that kind of interesting information.

If you want to know all the members of your variables before running the program in Matlab, there are two ways to do this:

  • write down on a sheet of paper the members of your structure before writing a program; I advise that in this case you make the initialization of all of the structure variable members in some initial part of the code
  • Matlab supports real classes through Object-oriented programming (personally I didn't use this approach, because I found it to be too verbose)

Upvotes: 1

Related Questions