-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplotarray.m
41 lines (37 loc) · 846 Bytes
/
plotarray.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
40
41
% plot and return a handle to every plotted point in the original shape of
% the input y.
%
% INPUTS:
% x: vector or matrix of size(y)
% y: vector or matrix
% varargin: additional arguments to pass to plot. If left empty we set to
% '.'
%
% OUTPUTS:
% outh: plot handles of size(y)
%
% outh = plotarray(x,y,varargin)
function outh = plotarray(x,y,varargin)
washold = ishold(gca);
hold(gca,'on');
plotarg = varargin;
if isempty(plotarg)
plotarg = {'.'};
end
sy = size(y);
sx = size(x);
if ~isequal(sx,sy)
% attempt to deal with x value vector case
x = repmat(x(:),[1 sy(2:end)]);
assert(isequal(size(x),sy),'x and y must have the same size');
end
outh = NaN(sy);
for h = 1:prod(sy)
if isnan(x(h)) || isnan(y(h))
continue;
end
outh(h) = plot(x(h),y(h),plotarg{:});
end
if ~washold
hold(gca,'off');
end