我想使用MATLAB绘制使用以下代码绘制的数据的傅里叶变换:
x = -2:0.01:2; % position vector
s = @(x)heaviside(x+1).*heaviside(-x)+heaviside(x).*heaviside(1-x); % Step
function between -1 and 1
phi = @(x) exp(-1./(1-x.^2)).*s(x); % Test function
d = @(t) integral(@(x)phi(x),0,t); % Data
fplot(d,[0,1])
然而,在绘制d的快速傅里叶变换时,没有一个MATLAB教程似乎有用,它是用变量积分定义的。
如果我尝试
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
s = @(x)heaviside(x+1).*heaviside(-x)+heaviside(x).*heaviside(1-x); % Step
function
phi = @(x) exp(-1./(1-x.^2)).*s(x); % Test function
d = @(t) integral(@(x)phi(x),0,t); %Data
plot(1000*t(1:50),d(1:50))
然后我收到以下错误:
Error using integral
A and B must be floating-point scalars.
Error in @(t)integral(@(x)phi(x),0,t)
我不知道如何解决这个问题。