octave plot legend

To add a legend to a plot in MATLAB or Octave, you can use the legend function. Here's an example:

x = 1:10;
y1 = x;
y2 = x.^2;

plot(x, y1, 'r', x, y2, 'b');
legend('y = x', 'y = x^2');

In this example, we create two lines (y = x and y = x^2) and plot them using the plot function. The 'r' and 'b' arguments specify the colors of the lines. The legend function is then used to add a legend to the plot, with the labels 'y = x' and 'y = x^2'.

Please let me know if you need further assistance!