function falias = alias(f,fs) % ALIAS generates an aliased frequency that corresponds to the % frequency and sampling rate given % % FALIAS = ALIAS(F,FS) % % returns the baseband frequency (between 0 and fs/2) FALIAS for a % given frequency F and sampling frequency FS if(f < 0 | fs < 0) error('Negative frequencies not allowed.'); end if (f > 0 & f < fs/2) error('No aliasing.'); % signal frequency f within Nyquist limits end k = round(f/fs); % find nearest multiple of sampling frequency falias = abs(k*fs-f); % calculate baseband alias frequency