MATLAB: How to give legend to a plot as a series

legend

Suppose I have multiple graphs on a plot for a parameter varying from -4 to 0.25 with difference of 0.25 between adjacent values (which is about 18 in number)? Can I say like legend y. where y is a variable varying from -4 to 0.25?

Best Answer

Example data:
x = 1:10;
h = plot(x, x'*p)
Create legend:
legend(h, cellstr(num2str(p', '%.2f')));