MATLAB如何使用fft函数提取仿真输出信号的频谱

%以下程序是对一段采样信号进行FFT分析,得到信号的频率成分:
%从“toworkspace”模块得到的数据在out数据中,需要用“data1=out.output”指令读取出来。读取后data1中也可能有多个数据,需要用data1.time\data1.data来使用。
%

fs=40e3; %fs:采样频率,Upccwave(:,1)为时间;Upccwave(:,2)为信号波形
figure(7);subplot(2,2,1);plot(input.time,input.data);%画出时域波形
figure(7);subplot(2,2,3);plot(output.time,output.data);%画出时域波形
title(‘时域原始信号’);
xlabel(‘时间t’);grid on;
number=0.01fs;%确定做多少点的FFT,这里是number点
yin=fft(input.data,number)./(number/2);%由于FFT的特性,输出数列幅值与原始信号频率分量幅值之间存在放大了(number/2)倍的关系;
%基波是放大number倍;这里是为了还原
yout=fft(output.data,number)./(number/2);
n=0:length(yin)-1;
f=fs
n/length(yin); %设置频率轴坐标
figure(7);subplot(2,2,2);bar(f,abs(yin));%axis([0,300,0,10e2]);%频域内的频谱信号
figure(7);subplot(2,2,4);bar(f,abs(yout));%axis([0,300,0,10e2]);%频域内的频谱信号
title(‘频域频谱信号’);
xlabel(‘频率Hz’);grid on;

在这里插入图片描述
数据导出方法
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值