2016-09-02

x = [55,76];
y = [180,240];

plot(x,y,'rx');
axis([0 100 0 300],"square");

% create a text object for each point
t = text(x, y, '');

% generate a cell array of labels - x and y must be row vectors in this case
c = strsplit(sprintf('%.2g,%.2g\n',[x;y]), '\n');
c(end) = []; % the final \n gives us an extra empty cell, remove it
c = c'; % transpose to match the dimensions of t

% assign each label to each text object
set(t, {'String'}, c);