I run
loglog(x,y);
legend(\'First script\');
from the first script.
Then, hold on;.
I run a similar second script.
I see two g
Another possible way to do this and it is called 'DisplayName':
hold all
for ind=1:3
x=[0:0.1:10];
plot(x, sin(x)+ind, 'DisplayName',['sin + ' num2str(ind)]);
end
legend(gca,'show')
Just use this property when plotting from wherever to whatever axes :)
There are even more things possible, like dynamic legend!
For more information see this: dynamic legend from undocumented matlab
EDIT
you have to update the legend after every run of a script. you can do this with the dynamic legend or by just legend('off'); legend('show')