|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
用了两种方法求边际谱~为何结果相差这么大呢?毕业在即,请高手指教,不甚感激
1.
clear all
clc
load('data.txt');
x=data(1:1000,2);
t=1:1000;
fs=50;
figure(10);
plot(1/fs*t,x);
xlabel('t/s');
ylabel('m/s^2');
%对信号作EMD分解,求出各IMF分量图和重构图及各IMF的时频图
[imf,ort,nbits]=emd(x);
%作出HHT归一化能量谱图(三维图),边际谱图和瞬时能量图
N=1000;
L=size(imf,1); % Number of components in the decomposition
% loop for on each component
S=[];
clear x z m p freq
x=imf'; % now each column is a compenent
z=hilbert(x); % analytic signal
m=abs(z); % module of z
p=angle(z); % phase of z
for i=1:L
freq(:,i)=instfreq(z(:,i)); % instantaneous frequency
ceilfreq(:,i)=ceil(freq(:,i)*N); % to have integer values-also do a smoothing given the number
for j=1:length(x)-2
S(ceilfreq(j,i),j+1)=m(j+1,i);
end
end
eps=0.00001; % to avoid zero values before the log
E=20*log(S.^2+eps); % Hilbert energ spectrum
% plot S
figure(90);
t=1:length(x); % time sample
f=t/length(x)*25; % frequency %%%%%%%%%
imagesc(t,f,E);
contour(t(1:999),1:50,E); %画出等高线图
surfl(1:999,1:500,S.^2); shading interp; colormap(gray);axis([1 1000 1 500 0 0.05])
% mesh(1:999,1:50,S.^2);
% mesh(1:999,1:50,S); %画出三维图
set(gca,'YDir','normal');
xlabel('时间采样点');
ylabel('Frequency/Hz'); %%%%%%%%%%%%%%%%%%%%
% ylabel('Normalized Frequency');
% axis([0 772 0 300]); %%%%%%%%%%%%%%%%%%%%%%
S1=sum(S.^2,1);figure(100);plot((1:999)*0.02,S1); %瞬时能量
figure(110);
S2=sum(S.^2,2);plot(1:500,S2,'r') %边际能量谱
figure(120);
S3=sum(S,2);plot(1:500,S3,'g') %边际谱
2.接上
%%% 求边际谱
[A,fa,tt]=hhspectrum(imf(1:end-1,:)); % A--瞬时幅值,fa--瞬时频率,tt--
[E,tt1,ff]=toimage(A,fa,tt,length(tt));%% ff--中心频率
% disp_hhs(E);colorbar;
% colormap(flipud(gray)) %显示灰度图
for k=1:size(E,1)
bjp(k)=sum(E(k,:))*1/fs;
end
f2=(0:N-3)/N*(fs/2); % fs/(2*N)是时频图上y方向的分辨率
figure(200)
plot(f2,bjp); %%% 作边际谱图
xlabel('频率 / Hz');
ylabel('幅值');
|
|