% Vector of initial conditions
y0 = [50 100 500 1000 1500];

% Create an array of different colors
% We need as many colors as we have initial conditions
c=hsv(length(y0)); 

%Create an empty array for the legend text
lt=[];

% For loop
for i = 1:length(y0)
   [X,Y] = ode45(@odef, [0 20], y0(i));
   plot(X,Y,'color',c(i,:))
   lt = strvcat(lt,num2str(y0(i))); % create legend text for this loop
   hold on;  % keep same plot window open
end

legend(lt,'Location','EastOutside');  % create legend
hold off; % the next time something is plotted it will be in a new window

