0% found this document useful (0 votes)
34 views2 pages

Assignment Sns

This document contains code to calculate the convolution of input signals x and h. It prompts the user to input values for the signals x and h, along with their lower and upper limits. It then calls a convolution function, passing in the input values, which calculates the convolution and plots the original signals and output signal y on a subplot. The convolution function calculates the convolution sum using a nested for loop to multiply and sum corresponding signal values within the limits.

Uploaded by

MaanHaider
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Assignment Sns

This document contains code to calculate the convolution of input signals x and h. It prompts the user to input values for the signals x and h, along with their lower and upper limits. It then calls a convolution function, passing in the input values, which calculates the convolution and plots the original signals and output signal y on a subplot. The convolution function calculates the convolution sum using a nested for loop to multiply and sum corresponding signal values within the limits.

Uploaded by

MaanHaider
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

x=input('Enter input signal x = '); % entering value of x lowerx=input('Enter lower limit of x = ');% enter value of lower limit of x upperx=input('Enter

upper limit of x = '); % enter value of Upper limit of x h=input('Enter input signal h = '); lowerh=input('Enter lower limit h = '); upperh=input('Enter upper limit h = '); % entering value of signal h % enter value of lower limit of h % entering value of upper limit of h

convolution(x,lowerx,upperx,h,lowerh,upperh) % passing values in function convolution.m % calling function of myconvolution % plotting of signals

subplot (2,2,1) stem(n1,X) title('x[n]') subplot (2,2,2) stem(n2,H) title('h[n]') subplot (2,2,3) stem(n,y) title('y[n]')

% convulution function
function y=myconv(x,lowerx,upperx,h,lowerh,upperh) a=lowerx:1:upperx; b=lowerh:1:upperh; lower=lowerx+lowerh; upper=upperx+upperh; n=lower:1:upper; for i=1:numel(n) for k=1:numel(x) if (i+1-k)<=0 y(i)=y(i)+(x(k)*0); elseif (i+1-k)>length(h) y(i)=y(i)+(x(k)*0); else y(i)=y(i)+(x(k)*h(i+1-k)); k=k+1; end end i=i+1; end

You might also like