I am not certain what numbers you want to plot. The left subplot plots both (x,y) values of the coordinate, and the right subplot only the y-values. Change the format descriptors to what you want. I used '%.1f' here.
The Code:
figure(1)
subplot(1,2,1)
x = randi(10, 1, 5);
y = randi(10, 1, 5);
L = strsplit(sprintf('(%.1f, %.1f)\n', [x(:) y(:)]'), '\n');
figure(1)
plot(x, y, '+r')
text(x, y, L(1:length(x)), 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
axis([-0.5 10.5 -0.5 10.5 ])
subplot(1,2,2)
x = randi(10, 1, 5);
y = randi(10, 1, 5);
L = strsplit(sprintf('%.1f\n', y(:)), '\n');
figure(1)
plot(x, y, '+r')
text(x, y, L(1:length(x)), 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
axis([-0.5 10.5 -0.5 10.5 ])
The Plot:
Best Answer