MATLAB: How can i write the number of line

information over the plot

Hi!
I have a 2D plot and I want to appear on each point of the graph, the number of lines corresponding to the matrix of data.
Is there any way?
Thank you!

Best Answer

Thodoris - if you want to write the row (or line) that each point corresponds to, try using the text function. Something like
figure;
data = [300 3.345
301 4.456
303 5.789];
xlim([min(data(:,1))-1,max(data(:,1))+1]);
ylim([min(data(:,2))-1,max(data(:,2))+1]);
sRows = num2str([1:size(data,1)]');
text(data(:,1),data(:,2),sRows);
The xlim and ylim are just used for illustration purposes to ensure that we can see the area we are interested in (that given by data). We then create a vector of strings, one for each row number using
sRows = num2str([1:size(data,1)]');
and then label each point in data with those strings using text.
Try the above and see what happens!