comparison spyh.m @ 443:12db86a8ec7b

Fix bug in spyh() when the matix has no non-zero elements.
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 19 Mar 2017 13:39:49 +0100
parents 5cb99f56f55e
children
comparison
equal deleted inserted replaced
440:0ef8965dd745 443:12db86a8ec7b
1 % spyh mimics the built in spy but returns a handle which allows modifying the plot. 1 % spyh mimics the built in spy but returns a handle which allows modifying the plot.
2 function h = spyh(A) 2 function h = spyh(A)
3 [n,m] = size(A); 3 [n,m] = size(A);
4 [I,J] = find(A); 4 [I,J] = find(A);
5 5
6 h = plot(J,I); 6 if ~isempty(J)
7 h.LineStyle = 'none'; 7 h = plot(J,I);
8 h.Marker = '.'; 8 h.LineStyle = 'none';
9 h.MarkerSize = 14; 9 h.Marker = '.';
10 h.MarkerSize = 14;
11 else
12 h = [];
13 end
10 14
11 a = gca; 15 a = gca;
12 xlim([0 m+1]); 16 xlim([0 m+1]);
13 ylim([0 n+1]); 17 ylim([0 n+1]);
14 axis square 18 axis square