% code
figure(2)
hold on;
tot_f=1;
for k=1:3:(size(Data_dim,2))
color_plot(tot_f,:)=[rand(1),rand(1),rand(1)];
h{tot_f}=plot(time, Y(:,k:k+2),'Color', color_plot(tot_f,:));
desired_legends{tot_f} = ... some appropriate string
xlabel('Time (s)')
ylabel('NU')
ax=gca;
ax.YLim=[0 50];
ax.XLim=[0 100];
tot_f=tot_f+1;
end
hold off;
group_handles = cellfun(@(V) V(1), h); %get first out of each group
legend(group_handles, desired_legends)