matlab中如何对一组数据进行fft变换后得到频谱图??
3个回答
东莞大凡
2024-08-07 广告
2024-08-07 广告
OpenCV标定板是东莞市大凡光学科技有限公司在相机标定中常用的工具。它通常由黑白格点按一定规则排列在平面上组成,如棋盘格或圆形格等。在相机标定时,将标定板置于不同位置和姿态下拍摄图像,利用OpenCV库中的函数检测标定板上的角点或圆心,进...
点击进入详情页
本回答由东莞大凡提供
推荐于2017-11-25
展开全部
如何画一个信号的频谱今天终于搞明白了,这么简单的东西今天才明白如何快速的用matlab画出,真是惭愧。光啃书本知识,会做题目真的是不够的,以后我要多多注意如何实践!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
比如
clear;
clc;
t=0:0.001:2;
n=2001;
Fs=1000;
Fc=200;
x=cos(2*pi*Fc*t);
y1=fft(x);
y2=fftshift(y1);
f=(0:2000)*Fs/n-Fs/2;
hold on;
plot(f,abs(y1),'r')
plot(f,abs(y2),'b')
这里需要在做了2001点FFT后将0到2000映射到真正的频谱-fs/2到+fs/2上才能成为真正的频谱
又如
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% .正弦波定义
f1=50; % 频率1
f2=100; % 频率2
fs=2*(f1+f2); % 采样频率
Ts=1/fs; % 采样间隔
N=120; % 采样点数
n=1:N;
y=sin(2*pi*f1*n*Ts)+sin(2*pi*f2*n*Ts); % 正弦波混合
figure(1)
subplot(2,1,1)
plot(y);
title('Signal')
subplot(2,1,2)
f=(1:120)*fs/200-fs/2; %这里相当于做了120点FFT,需要把1:120映射到-fs/2到+fs/2
F=abs(fftshift(fft(y)));
stem(f,F);
title('Amplitude Spectrum')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
再比如:
clc;
clear all;
fs=500;
t=0:1/fs:1.5;
f1=40; f2=20;
x=sin(2*pi*t*f1)+sin(2*pi*t*f2); %input signal
figure(1);
plot(t,x);
title('input signal x[n]'); %input signal wave
figure(3);
f=(0:750)*fs/751-fs/2;
plot(f,abs(fftshift(fft(x)))); % plot input signal's frequency spectrum
title('frequency components of the input singal')
希望大家以后能快速的画出频谱!
http://bbs.matwav.com/viewthread.php?tid=482120
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
比如
clear;
clc;
t=0:0.001:2;
n=2001;
Fs=1000;
Fc=200;
x=cos(2*pi*Fc*t);
y1=fft(x);
y2=fftshift(y1);
f=(0:2000)*Fs/n-Fs/2;
hold on;
plot(f,abs(y1),'r')
plot(f,abs(y2),'b')
这里需要在做了2001点FFT后将0到2000映射到真正的频谱-fs/2到+fs/2上才能成为真正的频谱
又如
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% .正弦波定义
f1=50; % 频率1
f2=100; % 频率2
fs=2*(f1+f2); % 采样频率
Ts=1/fs; % 采样间隔
N=120; % 采样点数
n=1:N;
y=sin(2*pi*f1*n*Ts)+sin(2*pi*f2*n*Ts); % 正弦波混合
figure(1)
subplot(2,1,1)
plot(y);
title('Signal')
subplot(2,1,2)
f=(1:120)*fs/200-fs/2; %这里相当于做了120点FFT,需要把1:120映射到-fs/2到+fs/2
F=abs(fftshift(fft(y)));
stem(f,F);
title('Amplitude Spectrum')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
再比如:
clc;
clear all;
fs=500;
t=0:1/fs:1.5;
f1=40; f2=20;
x=sin(2*pi*t*f1)+sin(2*pi*t*f2); %input signal
figure(1);
plot(t,x);
title('input signal x[n]'); %input signal wave
figure(3);
f=(0:750)*fs/751-fs/2;
plot(f,abs(fftshift(fft(x)))); % plot input signal's frequency spectrum
title('frequency components of the input singal')
希望大家以后能快速的画出频谱!
http://bbs.matwav.com/viewthread.php?tid=482120
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
将那个i输出线分0一t支q出来输入i到一b个kto file的模块就好了d,如果要转到EXECL中2的话将他们链接就好
e┳
e┳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询