%% step_example.m 
% Script to show the effect of a step input on a first order system
% BJ Furman
% 29AUG2015
%% Plotting the normalized step response assuming zero initial condition
clear all
close all
tau = 1;
% Excite with a step
t = linspace(0,5*tau,500);
Vnorm0 = 1-exp(-t/tau);
plot(t/tau,Vnorm0)
title('Normalized step response for a first order system')
xlabel('Time, (time constants)')
ylabel('Normalized amplitude')
grid
%% Plotting the normalized step response assuming a non-zero initial condition
clear all
close all
tau = 1;
Vinit_norm = [0.2 0.8 0.9];
% Excite with a step
t = linspace(0,5*tau,500);
norm_t = t/tau;
Vnorm0 = 1-exp(-norm_t);
Vnorm_init = 1+(Vinit_norm - 1)'*exp(-norm_t);
plot(norm_t,Vnorm0,norm_t,Vnorm_init)
title('Normalized step response for a first order system')
xlabel('Time, (time constants)')
ylabel('Normalized amplitude')
grid
legend(cellstr(num2str([0,Vinit_norm]','Vinit/V1=%-g')))
%%