charging a capacitor

t = linspace(0,5,300);
VL = 1;
VR = 6;
v = VR - (VR-VL)*exp(-t);
plot(t,v,'k','LineWidth',2);
grid on;
xlabel('time (t/\tau)');
ylabel('v (Volts)');
axis([0 5 0 8]);