One approach is to add a handle to the plot call (note the semicolon at the end to prevent printing all of the handles to the Command Window):
hp = plot(eStart:eStep:eEnd, XIR(:,transientCut:T),'g*' ,eStart:eStep:eEnd, XiR(:,transientCut:T),'b.' ...
,eStart:eStep:eEnd, XIr(:,transientCut:T),'r.' ,eStart:eStep:eEnd, Xir(:,transientCut:T),'k.');
then use the appropriate parts of it in the legend call:
legend(hp(1:201:end),'XIR','XiR','XIr','Xir')
That appeared to work correctly when I ran it (in R2020a, Update 4). (There are 804 Line objects in the plot, so a step size of 201 will get the first instance of each one.)
EDIT — (18 Jul 2020 aat 19:20)
Added plot image —
.
Best Answer