Matlab Let us start with looking at what a simple convolution does to signals. G
ID: 3887949 • Letter: M
Question
Matlab Let us start with looking at what a simple convolution does to signals. Generate the three signals below 1 with a suitable sampling frequency and a total duration of Ttot 0.1 s. If the signal is shorter than the total duration, add zeros to match Tot (this is called zero-padding - check the total number of samples you get in the end). Write separate functions for each signal (e.g generate_square), generate_ramp), zero_pad()) . A normalized square-wave signal (sometimes called 'boxcar-function') with T= 10 ms MATLAB ones (N,M), zeros (N,M) . A linear ramp of duration To -10 ms t if 0t To 0 nTo(t)= if t> To Think about which sampling rate to choose - it would be good to end up with integer numbers of samples... When generating a digital signal, you normally start with generating the time vector representing the points in time where the signal is being sampled. Then you assign the desired values at these samples Each of the three functions should have their own Matlab script, so the functions can be used later on.Explanation / Answer
Matlab code for above problem
clc;
clear all;
for t=1:101
rect(t)=10; % to get rect(t)
end
for t=1:11
lin(t)=0; % to get lin(t)
end
m=length(rect);
n=length(lin); % using length function to find length
if m>n
for t=n+1:101
lin(t)= 0; % to zero padding
end
else
for t=m+1:11
rect(t)= 0; % to zero padding
end
end
c1=conv(rect,rect);
c2=conv(lin,rect); % to do convolution
c3=conv(lin,lin);
subplot(6,1,1);
stem(rect);
title('rect(t)');
grid on;
subplot(6,1,2);
stem(lin);
title('lin(t)');
grid on;
subplot(6,1,3);
stem(c1);
title('convolution of (rect*rect)');
grid on;
subplot(6,1,4);
stem(c2);
title('Convolution of lin(t)*rect(t)');
grid on;
subplot(6,1,5);
stem(c3);
title('convulition of lin(t)*lin(t)');
grid on;
grid on;