Signal Processing blocks

by

 

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

[y,varargout]=mpointaverage(order,input,varargin)
function [y,varargout]=mpointaverage(order,input,varargin)
b=ones(1,order)/order;
if(length(input)<3*order)
    error('Length of the sequence must atleast be thrice the order');
else
    y=filter(b,1,input);
    h=filter(b,1,[1,zeros(1,(length(input)-1))]);
    if(nargout<=2)
        varargout={h};
    else
        error('Too many output arguments');
    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