This is a simplified version of the Savitzky-Golay MATLAB functions (
function y = sgolay_simplified(x, order, frameLen) % Compute the Vandermonde matrix S = (-(frameLen-1)/2:(frameLen-1)/2)' .^ (0:order); % Compute QR decomposition [Q,R] = qr(S,0); % Compute the projection matrix B B = Q*Q'; % Find the matrix of differentiators G = Q/R'; % Reshape X into the right dimension. [x, nshifts] = shiftdim(x); % Compute the transient on ybegin = B(end:-1:(frameLen-1)/2+2,:) * x(frameLen:-1:1,:); % Compute the steady state output ycenter = filter(B((frameLen-1)./2+1,:), 1, x); % Compute the transient off yend = B((frameLen-1)/2:-1:1,:) * x(end:-1:end-(frameLen-1),:); % Concatenate y = [ybegin; ycenter(frameLen:end,:); yend]; % Convert Y to the original shape of X y = shiftdim(y, -nshifts); end
I understand how it works and why the math is made that way. But I want to know a bit more.
In class I learned that filters have taps and these equal to the number of coefficients of the filter and when the filter is FIR, it equals to the length of the filter. So for this filter is the tap equal to the parameter
I thought like this because when the action of the filter is visualized, the filter acts like the moving average filter and takes in a specific amount of points to process at each step.
I want to make a function that'll take in parameters (
frameLen) and output an impulse response plot. How can I do this?