[英]How to plot FFT of a function defined in terms of an integral in MATLAB?
我想使用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)
我不知道该如何解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.