MATLAB: Hiding legend in plot

legendMATLABplot

Dear All,
I want to hide one legend from my graph. Could you please suggest a procedure or steps to do it.
Here is the code below to hiding my legend but doesn't work.
legend(h4,'off')
legend(h4,'toggle')
legend('h1','h2', 'h3', 'h4','h5');
Many Thanks in advance
Babai

Best Answer

I assume you have 5 handles, h1 through h5, but want to hide h4 from appearing in a legend. If that's the case, since you know all handles, the easiest way is probably
legend([h1 h2 h3 h5],{'h1','h2','h3','h5})