To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / utilities / UTIL_showStructureSummary.m @ 33:161913b595ae

History | View | Annotate | Download (1.32 KB)

1
function UTIL_showStructureSummary(structure, name, maxNoArrayValues)
2
% showStructureSummary prints out the values of a single structure
3
% The header is the structure name and each row is a field
4
% e.g. showStructureSummary(params,'params')
5
% This not the same as 'UTIL_showstruct'
6

    
7

    
8
if nargin<3
9
	maxNoArrayValues=20;
10
end
11

    
12
fprintf('\n%s:', name)
13

    
14
fields=fieldnames(eval('structure'));
15
% for each field in the structure
16
for i=1:length(fields)
17
	y=eval([ 'structure.' fields{i}]);
18
	if isstr(y),
19
		% strings
20
		fprintf('\n%s=\t''%s''',  fields{i},y)
21
	elseif isnumeric(y)
22
		% arrays
23
		if length(y)>1
24
			% vectors
25
			[r c]=size(y);
26
			if r>c, y=y'; end
27

    
28
			[r c]=size(y);
29
			if r>1
30
				%                 fprintf('\n%s.%s=\t%g x %g matrix',name, fields{i}, r, c)
31
				fprintf('\n%s=\t%g x %g matrix',fields{i}, r, c)
32

    
33
			elseif c<maxNoArrayValues
34
				%                     fprintf('\n%s=\t[%s]',  fields{i},num2str(y))
35
				fprintf('\n%s=',  fields{i})
36
				fprintf('\t%g',y)
37

    
38
			else
39
				fprintf('\n%s=\t %g...   [%g element array]', fields{i}, y(1),c)
40
			end
41
		else
42
			% single valued arrays
43
			%             fprintf('\n%s.%s=\t%s;', name, fields{i},num2str(y))
44
			fprintf('\n%s=\t%s', fields{i},num2str(y))
45
		end
46
	elseif iscell(y)
47
		fprintf('\n%s=\t cell array', fields{i})
48

    
49
	elseif isstruct(y)
50
		fprintf('\n%s=\t structure', fields{i})
51
	end,
52

    
53
end,
54
fprintf('\n')
55