plotfft.m
来自「用Matlab将Radio Frequency(RF)收发模块进行模型化。非常少」· M 代码 · 共 35 行
M
35 行
% PLOTFFT Function to plot FFT
%
% PLOTFFT (samples, fs, vpp) plots the magnitude of the FFT of samples, normalizing
% the frequency axis to the sampling rate fs and the magnitude to vpp.
%
% PLOTFFT (samples, fs, vpp, 'WINDOW') first multiplies by an appropriate
% window (bartlett, blackman, boxcar, hamming, hanning, or kaiser).
% The kaiser window requires beta as a fourth input.
%
% If the samples are complex, distinction is made between positive and negative
% frequencies.
function [] = sd_fft(samples, fs, vpp, varargin);
complex = 0;
if (iscmplx(samples)==1),
complex = 1;
end;
NFFT=2.^(ceil(log(length(samples))/log(2)));
if (complex == 0),
NumUniquePts = ceil((NFFT+1)/2);
f=(0:NumUniquePts-1)*fs/NFFT;
end;
if (complex == 1),
f=(-(NFFT/2):NFFT/2-1)*fs/NFFT;
end;
A = fftamp(samples, fs, f, varargin{:})*2/vpp;
plot(f, dbV(A));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?