Hi there,

I have a problem with the legend function in MatLab. I would like to link the name of the plotted variables to the legend, so that I only have to change the variables in the plot function.

An example:

t=1:10;
a=[1:10]';
b=[10:-1:1]';
c=ones(10)*5

plot(t,[a, b])
legend('a','b')

If I would like to change the plotted variables to [b, c]I have to change the strings in the legend also. Does someone know a way to overcome this?

Thanks in advance,

Jeroentje