Hi,
I understand that you are trying to plot step and impulse response of the system. As the range of ‘t’ is from 0 to 100 you can use “linspace” command. By using these ‘t’ values we will get proper cos signal. And for loops are not required to generate impulse and excitation signals.
t=linspace(0,100); % getting the t values from the linspace command
u=heaviside(t);
excitation=u.*cos(2*pi.*t);
impulse=exp(-0.05*t);
subplot(2,2,1)
plot(t,impulse)
title('impulse response')
subplot(2,2,2)
plot(t,excitation)
title('excitation')
c = conv(excitation,impulse,"same");
subplot(2,2,3)
plot(t,c)
title("Response")
step = conv(u,impulse,"same");
subplot(2,2,4)
plot(t, step)
title("Step Response")