时频分析方法的matlab实现

傅里叶变换 

function [ output_args ] = example3_7( input_args )
%EXAMPLE3_7 Summary of this function goes here
%   Detailed explanation goes here
clc;
clear;
fs=12800;%采样频率
s1=load('Sig1.txt');
s2=load('Sig2.txt');
ls=length(s1);   
figure(1)
subplot(211)
plot(s1);
title('正常振动信号');xlim([1 ls]);
xlabel('采样点数');ylabel('幅值');
subplot(212)
plot(s2);
xlabel('采样点数');ylabel('幅值');
title('漏油振动信号');xlim([1 ls]);
%%%%进行短时傅里叶变换
nfft=1024;        %fft点数 
[tfr,t,f]=tfrstft(s1,1:ls,nfft); %对正常信号进行短时傅里叶变换
[a,b]=size(tfr);
y=(1:a)./nfft*fs;%实际频率
x=(1:b);
figure(2)
subplot(211)
contour(x,y(1:nfft/2),abs(tfr(1:nfft/2,:))); 
xlabel('采样点数');ylabel('频率/Hz');colorbar
title('正常振动信号时频分布');
[tfr,t,f]=tfrstft(s2,1:ls,nfft); %对漏油信号进行短时傅里叶变换
[a,b]=size(tfr);
subplot(212)
contour(x,y(1:nfft/2),abs(tfr(1:nfft/2,:))); 
xlabel('采样点数');ylabel('频率/Hz');colorbar;
title('漏油振动信号时频分布');
end

小波变换

function [ output_args ] = example4_1( input_args )
%EXAMPLE4_1 Summary of this function goes here
%   Detailed explanation goes here
clc;
clear;
fs=1000;
t=0:1/fs:1;
s = chirp(t,30,1,500,'q');% 线性调频仿真信号
figure(1)
plot(t, s)
xlabel('时间t/s');ylabel('幅值');
% 连续小波变换时频图
wavename='cmor3-3';%复morlet小波
totalscal=256;
Fc=centfrq(wavename); % 小波的中心频率
c=2*Fc*totalscal;
scals=c./(1:totalscal);
f=scal2frq(scals,wavename,1/fs); % 将尺度转换为频率
coefs=cwt(s,scals,wavename); % 得到连续小波系数
figure(2)
imagesc(t,f,abs(coefs));
set(gca,'YDir','normal')
colorbar;
xlabel('时间 t/s');
ylabel('频率 f/Hz');
title('小波时频图');
% 短时傅里叶变换时频图
f = 0:fs/2;
tfr = tfrstft(s');
tfr = tfr(1:floor(length(s)/2), :);
figure(3)
imagesc(t, f, abs(tfr));
set(gca,'YDir','normal')
colorbar;
xlabel('时间 t/s');
ylabel('频率 f/Hz');
title('短时Fourier变换时频图');

end

原信号 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

深度学习的奋斗者

你的鼓励是我努力的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值