主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

fft

iddata 对象的快速傅里叶变换 (FFT)

说明

datf = fft(data) 使用快速傅里叶变换 (FFT) 算法将时域 iddata 对象数据转换为频域 iddata 对象 datfdata 包含实值信号并具有恒定的采样时间 Ts,而 datf 的频率值从 0 到奈奎斯特频率均匀分布。如果信号长度为偶数,则包含奈奎斯特频率;如果信号长度为奇数,则不包含奈奎斯特频率。为了保持信号功率和噪声水平,通过将每个变换除以信号长度的平方根来对 FFT 进行归一化。

示例

datf = fft(data,N) 指定转换长度 N。默认情况下,变换的长度由信号长度决定。如果 data 中的信号比 N 短,则包含 N 会强制 FFT 转换用零填充,否则截断信号。因此,真实信号情况下的频率数在 N 为偶数时为 (N/2)+1,在 N 为奇数时为 (N+1)/2。如果 data 包含多个试验,则 N 可以是相应长度的行向量。

示例

datf = fft(data,N,'complex') 指定包括负频率。对于实信号,默认值是 datf 仅包含非负频率,而对于复数值信号,始终包含负频率。为了在实际情况下强制执行负频率,请添加 'complex'

示例

示例

全部折叠

加载并绘制包含 300 个采样的时域数据 z1

load iddata1 z1;
plot(z1)

Figure contains 2 axes objects. Axes object 1 with title y1 contains an object of type line. This object represents z1. Axes object 2 with title u1 contains an object of type line. This object represents z1.

将数据转换至频域并绘图。

datf = fft(z1);
plot(datf)

Figure contains 4 axes objects. Axes object 1 with title y1 contains an object of type line. This object represents datf. Axes object 2 contains an object of type line. This object represents datf. Axes object 3 with title u1 contains an object of type line. This object represents datf. Axes object 4 contains an object of type line. This object represents datf.

加载数据。使用 fft 将时域数据 z1 转换到频域,使用转换长度 N100

load iddata1 z1;
datf = fft(z1, 100);
plot(datf)

Figure contains 4 axes objects. Axes object 1 with title y1 contains an object of type line. This object represents datf. Axes object 2 contains an object of type line. This object represents datf. Axes object 3 with title u1 contains an object of type line. This object represents datf. Axes object 4 contains an object of type line. This object represents datf.

加载数据。创建 2 频域对象 zf1zf2,在创建 zf2 时使用 'complex' 来包含负频率。

比较结果。

load iddata1 z1
zf1 = fft(z1,300);
zf2 = fft(z1,300,'complex');
h = plot(zf2,zf1);
legend('zf2','zf1')
opt = getoptions(h);
opt.FreqScale = 'linear';
opt.PhaseMatching = 'on';
setoptions(h,opt)
xlim([-32 32])

Figure contains 4 axes objects. Axes object 1 with title y1 contains 2 objects of type line. These objects represent zf2, zf1. Axes object 2 contains 2 objects of type line. These objects represent zf2, zf1. Axes object 3 with title u1 contains 2 objects of type line. These objects represent zf2, zf1. Axes object 4 contains 2 objects of type line. These objects represent zf2, zf1.

输入参数

全部折叠

时域数据,指定为 iddata 对象。

转换长度,指定为标量整数,或者对于多试验数据,指定为整数行向量。默认情况下,N 的每个元素等于相应的信号长度。

输出参量

全部折叠

频域数据,以 iddata 对象的形式返回。

提示

fft 产生的答案与基本 MATLAB® fft 函数不同。

  • 对于实信号,默认情况下,fft 仅计算频率范围的正部分的 FFT。MATLAB fft 计算整个频率范围的 FFT。

  • fft 将结果按 1/sqrt(N) 缩放,其中 N 是数据长度。MATLAB fft 不应用缩放。

版本历史记录

在 R2007a 中推出