I am running an old plotting routine in R2015b for the first time. It is crashing on a legend command because apparently the axes handle points to a deleted axes, and I am stumped on how to check for this. Can you please replace the line (if legh == 'handle to deleted Axes') to correctly check whether the axis is deleted?
hAx = gca;
if hAx == 'handle to deleted Axes'
isDeleted = true;
isDeleted = false;
disp('Axis exists. OK to add legend')