简体   繁体   中英

R like str() function in matlab/GNU Octave

I'd like to be able to view the structure of objects in Matlab/GNU Octave the same way as I do in R (using the str() function). Is there a function that does this? An example task would be returning nr rows and cols in matrix, but also all the arguments for a given function.

I'm aware that I could use both size() and help() (but not for function files ) separately to get this information.

There are several useful functions for displaying some information about Matlab objects (I can't say anything about Octave compatibility), but I'm not sure they'll provide the same detail as R's str() . You can display all of the methods of a class with the methods function, eg:

methods('MException')

which returns

Methods for class MException:

 addCause       getReport      ne             throw          
 eq             isequal        rethrow        throwAsCaller  

 Static methods:

 last

The what function will return similar results. Or methods can be used on an object of a given class:

ME = MException('Test:test','Testing');
methods(ME)

Similarly, you can view the properties with properties and the events with events .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM