0
我要繪製的傅立葉變換,使用MATLAB,這是繪製用下面的代碼數據:如何繪製在MATLAB中積分定義的函數的FFT?
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])
然而,沒有任何MATLAB教程似乎在密謀d的快速傅立葉變換是有用的,這是根據可變積分定義的。
如果我嘗試用
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)
我不知道該怎麼雖然解決這個問題。