-
Notifications
You must be signed in to change notification settings - Fork 0
/
anvar.m
35 lines (35 loc) · 1.35 KB
/
anvar.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
%% mianx: returns min and max of reshaped multidimmensional matrix
function anvar(in, varargin)
if not(isnumeric(in))
disp('anvar only handles numeric data')
else
reshapedData = reshape(in, [1 numel(in)]);
sizeCell = regexpi(mat2str(size(in)), '\s+', 'split');
sizeString = '';
for ii = 1:length(sizeCell)-1
sizeString = [sizeString sizeCell{ii} ' '];
end
sizeString = [sizeString sizeCell{end}];
sizeString = strrep(sizeString, '[', '');
sizeString = strrep(sizeString, ']', '');
disp(sprintf('\nmin max minabs maxabs mean std\n%.3e %.3e %.3e %.3e %.3e %.3e',...
min(reshapedData), max(reshapedData), min(abs(reshapedData)), max(abs(reshapedData)), mean(reshapedData), std(reshapedData)));
disp(sprintf('\n%d elements in shape: \n%s\n\n\n', numel(reshapedData), sizeString));
if numel(in) > 1 && isempty(varargin)
figure();
if ndims(in) == 2
[r c] = size(in);
if r > c
plot(in)
else
plot(in')
end
else
plot(reshapedData)
end
grid on
box off
set(gcf, 'name', 'anvar plot');
end
end
end