How can I modify the following MATLAB code to solve the prob
How can I modify the following MATLAB code to solve the problem on the picture?
clc; clear; close all;
%Definitions:
 tmin=0;
 tmax=8;
 stepSize=1e-3;
%Create time vector:
 t=tmin:stepSize:tmax;
%Preallocate Array:
 x=zeros(1,length(t));
 h=zeros(1,length(t));
%Create x(t):
 for i=1:length(t)
 if t(i) < 1
 x(i)=1;
 else
 x(i)=0;
 end
 end
%Create h(t):
 for i=1:length(t)
 if t(i) < 1
 h(i)=t(i);
 else
 h(i)=1;
 end
 end
%Convolution: y(t) = x(t)*h(t)
 yfull=conv(x,h,\'full\')*stepSize;
 y=yfull(1:length(t)); %Take only half the samples
%Plot results:
 subplot(3,1,1); plot(t,x); %x(t)
 xlabel(\'t\'); ylabel(\'x(t)\'); grid on;
 subplot(3,1,2); plot(t,h); %h(t)
 xlabel(\'t\'); ylabel(\'h(t)\'); grid on;
 subplot(3,1,3); plot(t,y); %y(t)
 xlabel(\'t\'); ylabel(\'y(t)\'); title(\'y(t) = x(t)*h(t)\'); grid on;
Solution
MODIFICATION IN MATLAB (NEW CODE):
clc; clear; close all;
%Definitions:
 tmin=0;
 tmax=8;
 stepSize=1e-3;
for k=1:20
 t(k) = k/20;
 i(k) = 0.4*(1-exp(-t(k)/tau1));
 end
 imax = i(20);
 tau2 = 200/200;
 for k = 21:120
 t(k) = k/20;
 i(k) = imax*exp(-t(k-20)/tau2);
 end
%Create time vector:
 t=tmin:stepSize:tmax;
%Preallocate Array:
 x=zeros(1,length(t));
 h=zeros(1,length(t));
%Create x(t):
 for i=1:length(t)
 if t(i) < 1
 x(i)=1;
 else
 x(i)=0;
 end
 end
%Create h(t):
 for i=1:length(t)
 if t(i) < 1
 h(i)=t(i);
 else
 h(i)=1;
 end
 end
%Convolution: y(t) = x(t)*h(t)
 yfull=conv(x,h,\'full\')*stepSize;
 y=yfull(1:length(t)); %Take only half the samples
% plot the current
 plot(t,i,\'o\')
 axis([0 6 0 0.18])
 title(\'Current of an RL circuit\')
 xlabel(\'Time, s\')
 ylabel(\'Current, A\')
%Plot results:
subplot(3,1,1); plot(t,x); %x(t)
 xlabel(\'t\'); ylabel(\'x(t)\'); grid on;
 subplot(3,1,2); plot(t,h); %h(t)
 xlabel(\'t\'); ylabel(\'h(t)\'); grid on;
 subplot(3,1,3); plot(t,y); %y(t)
 xlabel(\'t\'); ylabel(\'y(t)\'); title(\'y(t) = x(t)*h(t)\'); grid on;
(a) : h(t) = u(t-1) u(t-3)
(b): function dcrl = inductansoff(t,i)
 % function for RL circuit calculations
 Vs=50;
 i0=0;
 L=9;
 R=1;
 X = Vs/L;
 Y = i*R/L;
 if t<30
     dcrl = X - Y;
 else
    dcrl = -Y; %switched 0ff Vs=0
    if t>50
        dcrl = X - Y;
    else
        dcrl = -Y; %switched 0ff Vs=0
    end
 end



