I have a matlab function myfunction(var1,var2) which gives me a plot with a legend. I would like to generate more plots with this function in one graph. This works so far i.e. for 2 plots in one graph with:
myfunction(a,b)
hold on
myfunction(c,d)
hold off
The problem here is that the legend which is generated for each plot with:
legend(sprintf('%s%s',var1,' on ',var2))
legend('boxoff')
is only appearing for the last instance of myfunction (in this case with myfunction(c,d), there would be only one line of legend where it says 'c on d', but I would like to have two lines with 'a on b' and 'c on d')
So how can I add something to the legend without overwriting it?