fftpower.m

来自「FPGA输出数据的时频域分析GUI界面」· M 代码 · 共 22 行

M
22
字号
function [y,freq] = fftpower(x,startpoint,endpoint,fs,varargin)
%FFTPOWER calculate the fft power spectrum density data.
%   y = fftpower(x,startpoint,endpoint,fs), x could be real or complex,
%   (endpoint-startpoint+1) is the FFT point. fs is the sample frequency.

%   Author:Harrison Zheng
%   ShenZhen HYT Science&Technology CO.,LTD.
%   Date:2006.12.22
if (startpoint>=endpoint)
    error('start point could not be larger than end point');
end
[m,n] = size(x);
if ~(m==1 || n==1)
    error('input signal should be one dimension vector');
end
x = x(:);
fftpoint = endpoint - startpoint + 1;
y = abs(fftshift(fft(x(startpoint:endpoint),fftpoint)));
y = y(:);
freq = [-fs/2:fs/fftpoint:fs/2-fs/fftpoint]';

% End of Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?