diff +draw/labelPoint.m @ 0:48b6fb693025

Initial commit.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 17 Sep 2015 10:12:50 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+draw/labelPoint.m	Thu Sep 17 10:12:50 2015 +0200
@@ -0,0 +1,21 @@
+% Takes a variable number of points as inputs and plots them with a label to the current figure.
+%   label_pt(p)
+function label_pt(varargin)
+    for i = 1:length(varargin)
+        try
+            placelabel(varargin{i},inputname(i));
+        catch e
+            error('Could not place label for input %d, ''%s''. Not a valid point',i,inputname(i))
+        end
+    end
+end
+
+function placelabel(pt,str)
+    x = pt(1);
+    y = pt(2);
+    h = line(x,y);
+    h.Marker = '.';
+    h = text(x,y,str);
+    h.HorizontalAlignment = 'center';
+    h.VerticalAlignment = 'bottom';
+end
\ No newline at end of file