-
Notifications
You must be signed in to change notification settings - Fork 0
/
datadump.m
39 lines (35 loc) · 1.05 KB
/
datadump.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function datadump(data)
recurse(data, 0, []);
end
function result = recurse(data, level, addit)
indent = repmat(' | ',1,level);
if iscell(data) && ~ismymatrix(data)
result = iter_cell(data, level, addit);
elseif isstruct(data)
result = iter_struct(data, level, addit);
else
fprintf([indent,' +-Some data: ']);
disp(data);
result = data;
end;
end
function result = iter_cell(data, level, addit)
indent = repmat(' | ',1,level);
result = {};
fprintf([indent,'cell {\n']);
for i = 1:length(data)
result{i} = recurse(data{i}, level + 1, addit);
end;
fprintf([indent,'} cell\n']);
end
function result = iter_struct(data, level, addit)
indent = repmat(' | ',1,level);
result = struct();
fprintf([indent,'struct {\n']);
for i = fields(data)'
fld = char(i);
fprintf([indent,' +-field ',fld,':\n']);
result.(fld) = recurse(data.(fld), level + 1, addit);
end;
fprintf([indent,'} struct\n']);
end