Code covered by the BSD License  

Highlights from
struct2str recursive

Be the first to rate this file! 6 Downloads (last 30 days) File Size: 3.23 KB File ID: #18895

struct2str recursive

by Felix Zoergiebel

 

23 Feb 2008 (Updated 25 Feb 2008)

Displays a struct's content in a list box. View a substruct's content by selecting its list entry.

| Watch this File

File Information
Description

A small extension of struct2str by Marco Cococcioni:
- Selecting a substruct in the listbox results in calling struct2str again on the chosen substruct.
- Multidimensional struct-matrices are now completely displayed by making the input struct one-dimensional.

See struct2str for a detailed description.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
STRUCT2STR

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
14 Aug 2009 Peter Näsholm

To be able to handle vectors in the form
[1
2
3
4]

(instead of [1 2 3 4]),
one may for example change from row 152 into:

tmp = getfield(s,{l},fnames{f});
sz = size(tmp);
if (ndims(tmp) == 2) && (sz(2) == 1)
isflipped = 1;
tmp = tmp';
tmp = ['[' num2str(tmp) ']' char(39)];
else
isflipped = 0;
tmp = ['[' num2str(tmp) ']'];
end

                    str = sprintf(fmt1,str,fnames{f}, tmp);
if isflipped
                     cell_str{k} = sprintf(fmt11,fnames{f}, [ '[' num2str(getfield(s,{l},fnames{f})') ']' char(39) ] );
else
                     cell_str{k} = sprintf(fmt11,fnames{f}, [ '[' num2str(getfield(s,{l},fnames{f})) ']' ] );
end
                    k = k + 1;

(and then as the rest of the original code)

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
structures Felix Zoergiebel 22 Oct 2008 09:50:25
cell arrays Felix Zoergiebel 22 Oct 2008 09:50:25
struct Felix Zoergiebel 22 Oct 2008 09:50:25
substuct Felix Zoergiebel 22 Oct 2008 09:50:25
char strings Felix Zoergiebel 22 Oct 2008 09:50:25
conversion Felix Zoergiebel 22 Oct 2008 09:50:25
struct display Felix Zoergiebel 22 Oct 2008 09:50:25
substruct Felix Zoergiebel 22 Oct 2008 09:50:25

Contact us at files@mathworks.com