|
楼主 |
发表于 2010-11-14 21:08
|
显示全部楼层
回复 2 # pandacute 的帖子
你好,我的边际谱和FFT谱主要是形状和幅度不同,而且幅度差别特别离谱,我觉得我程序应该没错吧,是振动论坛上的边际谱程序拿来用的啊,im是toimage文件的输出,也不是dB值啊,就是幅度值,不知问题出在哪里?求指点!
toimage.m文件如下:
function [im,tt] = toimage(A,f,t,splx,sply)
% [im,tt] = TOIMAGE(A,f,t,splx,sply) transforms a spectrum made
% of 1D functions (e.g., output of "spectreh") in an 2D image
%
% inputs : - A : amplitudes of modes (1 mode per row of A)
% - f : instantaneous frequencies
% - t : time instants
% - splx : number of columns of the output im (time resolution).
% If different from length(t), works only for uniform
% sampling.
% - sply : number of rows of the output im (frequency resolution).
% outputs : - im : 2D image of the spectrum
% - tt : time instants in the image
%
% utilisation : [im,tt] = toimage(A,f);[im,tt] = toimage(A,f,t);[im,tt] = toimage(A,f,sply);
% [im,tt] = toimage(A,f,splx,sply);[im,tt] = toimage(A,f,t,splx,sply);
DEFSPL = 400;
if nargin < 3
t = 1:size(A,2);
sply = DEFSPL;
splx = length(t);
else
if length(t) == 1
tp = t;
t = 1:size(A,2);
if nargin < 4
sply = tp;
splx = length(t);
else
if nargin > 4
error('too many arguments')
end
sply = splx;
splx = tp;
end
else
lt = length(t);
if nargin < 5
sply = splx;
splx = lt;
end
if nargin < 4
sply = DEFSPL;
splx = lt;
end
if nargin > 5
error('too many arguments')
end
end
end
lt=length(t);
im=[];
im(splx,sply) = 0;
for i=1:size(f,1)
for j = 1:lt
ff=floor(f(i,j)*2*(sply-1))+1;
if ff <= sply % in case f(i,j) > 0.5
im(floor(j*(splx-1)/lt)+1,ff)=im(floor(j*(splx-1)/lt)+1,ff)+A(i,j);
end
end
end
for i = 1:splx
tt(i) = mean(t(floor((i-1)*lt/(splx))+1:floor(i*lt/(splx))));
end
im=fliplr(im)'; %颠倒f,t轴,f向上递增,t向右递增
|
|