Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab can';得不到正确的fft图_Matlab_Signal Processing - Fatal编程技术网

Matlab can';得不到正确的fft图

Matlab can';得不到正确的fft图,matlab,signal-processing,Matlab,Signal Processing,我对频谱的绘制有问题,我有一个音频文件,在该文件上运行fft函数并尝试绘制其频谱: fileName = 'stuff.wav' ; [y, Fs] = audioread(fileName); Y = fft(y(:,1)); Y = Y / length(y); plot(fftshift(abs(Y)); 下面是我得到的: 震级正确,但频率不正确 所以我写了一个小脚本来测试这个: fs =8000; t = 0:1/fs:10; x = 3*sin(2*pi*5*t); U =

我对频谱的绘制有问题,我有一个音频文件,在该文件上运行
fft
函数并尝试绘制其频谱:

    fileName = 'stuff.wav' ;
[y, Fs] = audioread(fileName);
Y = fft(y(:,1));
Y = Y / length(y);
plot(fftshift(abs(Y));
下面是我得到的:

震级正确,但频率不正确

所以我写了一个小脚本来测试这个:

fs =8000;
t = 0:1/fs:10;
x = 3*sin(2*pi*5*t);
U = abs(fft(x));
stem(t,fftshift(U));
axis([-20 20 -5 5]);
结果是:

为什么峰值在正确的位置,意思是5,但我在-5负频率中发现了第二个峰值,为什么我可以看到它,以及如何正确缩放X轴?
谢谢你的帮助

您正在绘制FFT结果(
U
)与时间的关系,这没有多大意义。首先生成频率轴值,然后在绘制
U
时使用该值:

%// Same as in your code:
fs = 8000;
t = 0:1/fs:10;
x = 3*sin(2*pi*5*t);
U = abs(fft(x));

%// Do the following changes to your code:
f = -fs/2:fs/(numel(t)-1):fs/2; %// frequency axis
stem(f, fftshift(U)); %// plot U versus frequency
axis([-10 10 0 15e4]); %// zoom in to see -5 Hz and 5 Hz values

您正在绘制FFT结果(
U
)与时间的关系,这没有多大意义。首先生成频率轴值,然后在绘制
U
时使用该值:

%// Same as in your code:
fs = 8000;
t = 0:1/fs:10;
x = 3*sin(2*pi*5*t);
U = abs(fft(x));

%// Do the following changes to your code:
f = -fs/2:fs/(numel(t)-1):fs/2; %// frequency axis
stem(f, fftshift(U)); %// plot U versus frequency
axis([-10 10 0 15e4]); %// zoom in to see -5 Hz and 5 Hz values

您正在绘制FFT结果(
U
)与时间的关系,这没有多大意义。首先生成频率轴值,然后在绘制
U
时使用该值:

%// Same as in your code:
fs = 8000;
t = 0:1/fs:10;
x = 3*sin(2*pi*5*t);
U = abs(fft(x));

%// Do the following changes to your code:
f = -fs/2:fs/(numel(t)-1):fs/2; %// frequency axis
stem(f, fftshift(U)); %// plot U versus frequency
axis([-10 10 0 15e4]); %// zoom in to see -5 Hz and 5 Hz values

您正在绘制FFT结果(
U
)与时间的关系,这没有多大意义。首先生成频率轴值,然后在绘制
U
时使用该值:

%// Same as in your code:
fs = 8000;
t = 0:1/fs:10;
x = 3*sin(2*pi*5*t);
U = abs(fft(x));

%// Do the following changes to your code:
f = -fs/2:fs/(numel(t)-1):fs/2; %// frequency axis
stem(f, fftshift(U)); %// plot U versus frequency
axis([-10 10 0 15e4]); %// zoom in to see -5 Hz and 5 Hz values

谢谢你的回答,但当我在音频文件中尝试时,结果并没有真正意义,至少当我将其与audacity进行比较时是这样result@Engine好的,5-Hz信号的方法应该适用于任何音频文件…谢谢你的回答,但是当我在音频文件上尝试时,结果没有真正意义,至少当我把它和胆大妄为相比的时候result@Engine好的,5-Hz信号的方法应该适用于任何音频文件…谢谢你的回答,但是当我在音频文件上尝试时,结果并没有真正意义,至少当我将其与audacity进行比较时result@Engine好,用于5-Hz信号的方法应该适用于任何音频文件…感谢您的回答,但当我在音频文件上尝试时,结果并没有真正意义,至少当我将其与audacity进行比较时result@Engine嗯,用于5赫兹信号的方法应该适用于任何音频文件。。。