Certainly - just use a for loop.
nplots = 10;
plot(rand(nplots))
for j=1:nplots
legtxt{j,1} = strcat("This is plot #",num2str(j));
end
legend(legtxt);
nplots would be replaced with the variable in your code. Alternatively,
clear all
nplots = 3;
namelist = {"a";"b";"c";"d";"e"}
plot(rand(nplots))
for j=1:nplots
legtxt{j,1} = namelist{j,1};
end
legend(legtxt);
has a long user-defined list of names, and then takes only as many as needed for the legend.
On Mon, Apr 20, 2020 at 10:45 AM Renato S. Yamane <
address@hidden> wrote:
Thanks Brett,
I forgot to tell that the amount of graphs is not fixed.
The amount of graphs is a variable in the code.
There is an way to "legtxt" (in your example) keep increasing until reach the number of graphs?
Example, if I have 10 graphs, the legtxt should be from {1,1} til {10,1}
Many thanks,
Renato