Set up a loop that evaluates the function for each c-value and adds the line to the plot.
allc = [c_1, c_2, c_3, c_4];
colors = {'b' 'g' 'r' 'k'};
figure(1)
hold on
for c = 1:numel(allc)
timespan= [0 3];
[t,x]= ode45 (@ (t,x) jff(t,x,m,k,allc(c)),timespan,[x0;x_dot]);
plot(t,x(:,1),colors{c})
end
hold off
title ('Position Response vs. Time')
legend ('Undamped','Underdamped','Critically Damped','Overdamped')
xlabel('Time')
ylabel ('Position Response')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/275460/image.png)