Signal Processing blocks

by

 

The folder contains 2 m-files: 1) intg.m 2)mpointaverage.m

[y varargout]=intg(input,intv,varargin)
function [y varargout]=intg(input,intv,varargin)
imp=[1 zeros(1,length(input)-1)];
unit=ones(1,length(input));
h=intv*unit-(intv/2)*imp;
if(nargout<=2)
    varargout={h};
else
    error('Too many output arguments');
end
res=conv(input,h);
y=ones(1,length(input));
for k=1:length(input)
    y(k)=res(k);
end
if(size(varargin,2)<=1)
    if(strcmp(varargin,'fig'))
        stem(input),xlabel('n'),ylabel('x(n)'),title('Input Sequence');
        figure,stem(y),xlabel('n'),ylabel('y(n)'),title('Output Sequence');
        figure,stem(h),xlabel('n'),ylabel('h(n)'),title('Impulse response');
    else
       if(strcmp(varargin,' '))
       error('Invalid input argument'); 
       end
    end
else
    error('Too many input arguments');
end
end

Contact us