I'm working with the following Code to copy a saved plot into another.
fig1 = openfig('ABC.fig');
fig2 = openfig('DEF.fig', 'invisible');
copyobj(fig2.Children.Children, fig1.Children);
This works fine, as long as I'm not using a legend in fig2, then I get a Error message for using too many input arguments in copyobj. In the documentation I learnt, that copyobj doesn't copy the context menu of legends, so I'm asking for your help in copying the legend as well.