阶跃函数的时域DFT [英] DFT of time domain for step function

查看:190
本文介绍了阶跃函数的时域DFT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在Matlab中进行DFT,这是我在Matlab中的代码.我的代码的哪一部分有问题,我的采样是错误的???如果您回答我的问题,我将不胜感激:

I have been working on DFT in Matlab recently, here is my code in Matlab. which part of my code has problem, my sampling is wrong??? I'll be grateful if you answer my question:

dt = 0.01;      %sampling time interval
Fs = 1/dt;       %sampling rate
t = 0:dt:45;     %Time vector
t0 = 5;          %duration of applied stress
N = length(t);   %number of sample points
y_timedomain = heaviside(t)-heaviside(t-t0);     %the step function
figure (1)
plot(y_timedomain)
axis([-100,1000,-0.2,1.2]);
y_freqDomain=abs(fft(y_timedomain));     % fft of step funcion, y(t)
z = fftshift(y_freqDomain);              % DFT and shift center to zero
figure (2)
plot(linspace(-10,10,length(y_freqDomain)),z)
xlabel('Sample Number')
ylabel('Amplitude')
title('Using the Matlab fft command')
grid
axis([-.3,.3,0,1000]);

与此同时,我对此代码有2个问题: 1-我的步进函数在0时的幅度为1/2,但是我希望我的0在0时的步进函数为0,而不是1/2(例如矩形),但是我不知道如何校正它??? 2-当我们进行DFT时,是否应始终使用移位FFT"? 如果您给我有关此代码的建议,我将非常感激.

meanwhile, I have 2 question about this code: 1- my step function at 0 time, has magnitude of 1/2, but i want my step function at 0 time be 0 instead of 1/2,( such as rectangle shape), but i don't know how to correct it??? 2- when we do DFT, should we use "shift FFT" always???? if you give me your advice about this code i will be really thankful.

推荐答案

重载步阶功能

MATLAB确实使用1/2x=0定义了步进函数(请参见

MATLAB does define the step function with 1/2 for x=0 (see http://de.mathworks.com/help/symbolic/heaviside.html?refresh=true), if you wish otherwise you could define your own function, maybe like this here?

mystep = @(x) sign(max(x, 0));

fftshift

fftshift

不,您不必总是使用fftshift,这实际上取决于您实际要执行的操作.原则上,ftf不太适合步进功能之类的信号(如果要进行频率分析,在这种情况下,我建议进行解析ft!).有很多副作用(我现在不想进入这个领域),而fftshift是帮助解决这些问题的工具之一.阅读文档(doc fftshift)并大致了解有关ft的更多信息.

No you don't have to use fftshift always, that really depends on what exactly you want to do. In principle, the fft is not very suited for signals like the step function (if you want to do some frequency analysis, in that particular case, I recommend to do analytical ft!). There are many side effects (I don't want to go into that field right now) and fftshift is one of the tools to help deal with those. Read the doc (doc fftshift) and learn more about the ft in general.

这篇关于阶跃函数的时域DFT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆