The simplest solution here is to leverage legend. If legend doesn't make sense in your case because all the lines in the plot have the same colour, then I would suggest fixing that since that's easier.
If you're plotting multiple lines using a for loop or a function with some command like this:
which results in all lines being the same colour, then you can remove the line colour specification. Use this instead:
This results in each line having it's own colour and then the legend will start making sense. It would look like this example. Notice that the line's colour is not specified in both the plot commands in that example.
Another simple approach
However, if you're particular about having the line's name show up in the data tip, that can be done. You will have to customize the data tip and here's an article which shows how that can be done: Create Custom Data Tips
Note that in this example, there exists a third array (statelabel) which contains the custom information for each plotted point. You would have to create such a cell array for each line that you plot.
If you are plotting the i-th line, you could create the cell array for the custom data tip as follows:
lineNum = cellstr(num2str(i));
row = dataTipTextRow('Line No', repelem(lineNum,1,numel(x)));
h.DataTipTemplate.DataTipRows(end+1) = row;