LegendVector = {'Apple', 'Orange', 'Banana'};
ActualLegend = [~cellfun('isempty', Performance.Apple),...
~cellfun('isempty', Performance.Orange), ...
~cellfun('isempty', Performance.Banana)];
LegendVector = LegendVector(ActualLegend);
legend(LegendVector);
This is by far what came to my mind, is there any other way to simplify the redundent cellfun in my code?