dt=.01; goa=0; stopa=1/2; gob=0; stopb=2; ta=goa:dt:stopa; a=exp(-ta); tb=gob:dt:stopb; b=exp(-tb); tc=goa+gob:dt:stopa+stopb; c=dt*conv(a,b); subplot(311);plot(ta,a); subplot(312);plot(tb,b); subplot(313);plot(tc,c); %% % Task1 Part 1. dt=.01; goa=1/2; stopa=2; gob=0; stopb=2; ta=goa:dt:stopa; a=exp(-3*ta); tb=gob:dt:stopb; c = (tb >= k * 4) .* (tb < (k + 1) * 4); tc=goa+gob:dt:stopa+stopb; y=dt*conv(a,c); subplot(311);plot(ta,a); subplot(312);plot(tb,c); subplot(313);plot(tc,y); %% % Task 1 Part 2 dt=.01; goa=0; stopa=1/2; gob=0; stopb=2; ta=goa:dt:stopa; a=exp(-3*ta); tb=gob:dt:stopb; b=exp(4*tb); tc=goa+gob:dt:stopa+stopb; c=dt*conv(a,b); subplot(311);plot(ta,a); subplot(312);plot(tb,b); subplot(313);plot(tc,c); % Define the time variable t t = -1:0.01:1; % Adjust the time range as needed % Define the function a(t) a = exp(-3*t) .* (t >= 0); % u(t) is represented by (t >= 0) % Calculate the convolution of a(t) and c(t) w = zeros(size(t)); % Initialize the result % Define the intervals for c(t) where each unit step function exists k_values = -25:25; % Choose a suitable range of k values % Loop over k values and calculate the convolution for k = k_values % Calculate the unit step function that represents c(t) c_k = (t >= k * 4) .* (t < (k + 1) * 4); % Compute the convolution for this unit step function w = w + conv(a, c_k, 'same'); end % Plot the result plot(t, w); xlabel('Time (t)'); ylabel('w(t)'); title('Convolution of a(t) and c(t)'); grid on; %% % Define the time variable t t = -1:0.01:1; % Adjust the time range as needed % Define the functions a(t) and b(t) a = exp(-3*t) .* (t >= 0); % u(t) is represented by (t >= 0) b = exp(4*t) .* (t <= 0); % u(-t) is represented by (t <= 0) % Compute the convolution of a and b w = conv(a, b, 'same'); % 'same' option keeps the output size the same as the input % Plot the result plot(t, w); xlabel('Time (t)'); ylabel('w(t)'); title('Convolution of a(t) and b(t)'); grid on; %% % Define the time variable t t = -1:0.01:1; % Adjust the time range as needed % Define the function a(t) a = exp(-3*t) .* (t >= 0); % u(t) is represented by (t >= 0) % Calculate the convolution of a(t) and c(t) w = zeros(size(t)); % Initialize the result % Define the intervals for c(t) where each unit step function exists k_values = -25:25; % Choose a suitable range of k values % Loop over k values and calculate the convolution for k = k_values % Calculate the unit step function that represents c(t) c_k = t .* (t >= k * 4) .* (t < (k + 1) * 4); % Compute the convolution for this unit step function w = w + conv(a, c_k, 'same'); end % Plot the result plot(t, w); xlabel('Time (t)'); ylabel('w(t)'); title('Convolution of a(t) and c(t)'); grid on; %% % Define time parameters and signals as in the previous code dt = 0.01; goa = 0; stopa = 1/2; gob = 0; stopb = 2; ta = goa:dt:stopa; a = exp(-3*ta); tb = gob:dt:stopb; b = exp(4*tb); % Define c(t) and d(t) tc = goa + gob:dt:stopa + stopb; c = dt * conv(a, tb); % c(t) = a(t) * b(t) % Define a new time vector for d(t) stopd = 4; % Adjust the stop time for d(t) as needed td = goa:dt:stopd; d = td .* (td >= 0) .* (td <= 2); % d(t) = t * u(t) * (1 - u(t - 2)) % Compute the convolutions wx = dt * conv(a, c); % w(t) = a(t) * c(t) xy = dt * conv(b, d); % x(t) = b(t) * d(t) bz = dt * conv(b, c); % y(t) = b(t) * c(t) % Plotting subplot(411), plot(ta, a), xlabel('t'), ylabel('a(t)'); subplot(412), plot(tb, b), xlabel('t'), ylabel('b(t)'); subplot(413), plot(tc, c), xlabel('t'), ylabel('c(t)'); subplot(414), plot(td, d), xlabel('t'), ylabel('d(t)');