Skip to content

Instantly share code, notes, and snippets.

@mattdsp
mattdsp / cfirls.m
Last active January 17, 2024 12:06
Least-squares FIR filter design with prescribed magnitude and phase responses and with possibly complex coefficients
function h = cfirls(N,f,d,w,hreal)
% function h = cfirls(N,f,d,w,hreal)
% Least-squares FIR filter design with prescribed magnitude and phase
% responses and with possibly complex coefficients
%
% h real or complex-valued impulse response
% N desired filter length
% f frequency grid
% for complex-valued filters ('hreal=0'): -1 <= f < 1
% ( '1' corresponds to Nyquist) or 0 <= f < 2