Code Matlab to calculate Regular Convolution using DFT Code
Code Matlab to calculate \"Regular Convolution\" using DFT
Code a MATLAB function to calculate \"regular convolution\", use DFT method. (Should NOT use MATLAB function \'conv\'). Code a MATLAB function to realize the \"circular flip\". Let x[n] be a periodic signal with one period given by [1, -2, 3, -4, 5, -6, ] with the n = 0 zero index as shown. It is the input to a LTI system with impulse response h[n] = 0.8|n|. Determine one period of the output sequence y[n].Solution
MATLAB CODE:
 clear all;
 x=input(\'Enter x: \'); % inputs sequence in the form [1 1]
 h=input(\'Enter h: \'); %impulse response of filter in the form [1 1]
 m=length(x); %length of sequence
 n=length(h);
 X=[x,zeros(1,n)]; % appends zeros to make x and h of same length = n+m
 H=[h,zeros(1,m)];
 for i=1:n+m-1 % for loop for length of output sequence for n+m-1
 Y(i)=0;
 for j=1:m
 if(i-j+1>0)
 Y(i)=Y(i)+X(j)*H(i-j+1); % DFT formula
 else
 end
 end
 end
 stem(Y); % plots Y in discrete
 ylabel(\'Y[n]\');
 xlabel(\'n\');
 title(\'Convolution of Two Signals \');

