声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1490|回复: 3

[FFT] 求数据的频谱图

[复制链接]
发表于 2007-3-23 10:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
可能是很笨的问题,但是却困扰了一个星期。希望高手、大侠能够帮助,领导天天催,实在没办法了。是这样:每天得到一个数据,共268天,也就是有268个数据,想求这269个数据的频谱图,不知道怎么求,用fft,然后呢,实在搞不懂,不是搞这个的,可是硬着头皮也不行,求求你们啦,:'(
部分数据,y=[ 309  280 2526  3587  3328 4073   4569  3840  4890  5494  10200   4626  5630  6105 5102  6242  5076 6108   7110  6024],最后一天的期限了,:@Q

[ 本帖最后由 xinyuxf 于 2007-7-22 12:11 编辑 ]
回复
分享到:

使用道具 举报

发表于 2007-3-24 10:35 | 显示全部楼层
clc
clear all
file_choice = input('');
%读取外部文件
if(file_choice==1)
    [filename, pathname] = uigetfile('*.*');
    filename = fullfile(pathname, filename);
    fid = fopen(filename,'r');
    channel = fscanf(fid,'%g ',[1 inf]);
else
    channel = input(' Enter the matrix name:  ');
end


motor_parameter.sample_fre=5000;
motor_parameter.analysis_num=length(channel);

t=0:1/motor_parameter.sample_fre:motor_parameter.analysis_num/motor_parameter.sample_fre;
y=fft(channel);                                                    %傅立叶变换


%fft及时间曲线绘图

                                                      
    motor_parameter.analysis_num=length(channel);                                %信号的分析点数
    t=0:1/motor_parameter.sample_fre:motor_parameter.analysis_num/motor_parameter.sample_fre;
    f=motor_parameter.sample_fre*(0:motor_parameter.analysis_num-1)/motor_parameter.analysis_num;
    subplot(2,2,1)
   
    plot(t(1:motor_parameter.analysis_num),channel(1:motor_parameter.analysis_num))   %绘制时域波形
    subplot(2,2,2)
   
    plot(f(1:motor_parameter.analysis_num/2),2*abs(y(1:motor_parameter.analysis_num/2))/motor_parameter.analysis_num)  %绘制幅频波形

评分

1

查看全部评分

发表于 2007-3-24 10:37 | 显示全部楼层
motor_parameter.sample_fre是采样频率,根据你的情况改下,不知道有用不
 楼主| 发表于 2007-3-28 10:04 | 显示全部楼层

非常感谢lvma6 !

非常感谢lvma6 !
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-18 15:59 , Processed in 0.069732 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表