yao_zq 发表于 2007-7-18 16:34

求助:关于EMD的toimage.m

EMD分解后想得到信号的频谱信息
运行Grilling 提供的程序toimage.m时,builtin报错,说accumarray有问题
是怎么回事

yao_zq 发表于 2007-7-18 16:38


回复 #39 jingrenzhi 的帖子


对应8楼的程序
t=1:500;
t=t*1/400;
x1=sin(2*pi*20*t);
x2=0.4*sin(2*pi*40*t+140);
z=x1+x2
plot(t,z)
y= linspace(1,2,500);%添加趋势项
z=z+y
imf=emd(z);
emd_visu(z,1:length(z),imf)
=hhspectrum(imf);
=toimage(A,f);
disp_hhs(im);
colormap(flipud(gray))

[ 本帖最后由 zhangnan3509 于 2007-6-1 15:35 编辑 ]


就是这个http://forum.vibunion.com/forum/viewthread.php?tid=44797&extra=page%3D1%26amp%3Bfilter%3Dtype%26amp%3Btypeid%3D187&page=3

yao_zq 发表于 2007-7-18 16:40

没有得到zhangnan3509 相应的效果阿

指点下

yao_zq 发表于 2007-7-18 16:48

toimage.m里有句:
im = accumarray(,A(:),);

就是这个accumarray函数的问题

zhlong 发表于 2007-7-18 19:39

回复 #4 yao_zq 的帖子

有个帖子讨论过accumarray的问题,你可以搜索一下。
另外这个函数是新版的程序里才有的。

hahaer 发表于 2008-12-19 22:42

工具箱里有啊

我再贴下

%TOIMAGEtransforms a spectrum made of 1D functions in an 2D image
%
% = TOIMAGE(A,f,t,splx,sply) transforms a spectrum made
% of 1D functions (e.g., output of "hhspectrum") 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
%            - ff   : centers of the frequency bins
%
% Examples : = toimage(A,f); = toimage(A,f,t); = toimage(A,f,sply);
%             = toimage(A,f,splx,sply); = toimage(A,f,t,splx,sply);
%
%
% See also
%emd, hhspectrum, disp_hhs
%
% G. Rilling, last modification 3.2007
% gabriel.rilling@ens-lyon.fr

function = toimage(A,f,varargin)


DEFSPL = 400;

error(nargchk(2,5,nargin));

switch nargin
case 2
    t = 1:size(A,2);
    sply = DEFSPL;
    splx = length(t);
case 3
    if isscalar(varargin{1})
      t = 1:size(A,2);
      splx = length(t);
      sply = varargin{1};
    else
      t = varargin{1};
      splx = length(t);
      sply = DEFSPL;
    end
case 4
    if isscalar(varargin{1})
      t = 1:size(A,2);
      sply = varargin{1};
      splx = varargin{2};
    else
      t = varargin{1};
      sply = varargin{2};
      splx = length(t);
    end
case 5
    t = varargin{1};
    splx = varargin{2};
    sply = varargin{3};
end
if isvector(A)
A = A(:)';
f = f(:)';
end


if issparse(A) || ~isreal(A) || length(size(A)) > 2
error('A argument must be a real matrix')
end
if issparse(f) || ~isreal(f) || length(size(f)) > 2
error('f argument must be a real matrix')
end
if any(size(f)~=size(A))
error('A and f matrices must have the same size')
end
if issparse(t) || ~isreal(t) || ~isvector(t) || length(t)~=size(A,2)
error('t argument must be a vector and its length must be the number of columns in A and f inputs')
end
if ~isscalar(splx) || ~isreal(splx) || splx ~= floor(splx) || splx <= 0
error('splx argument must be a positive integer')
end
if ~isscalar(sply) || ~isreal(sply) || sply ~= floor(sply) || sply <= 0
error('splx argument must be a positive integer')
end

if any(diff(diff(t))) && splx ~= length(t)
warning('toimage:nonuniformtimeinsants','When splx differs from length(t), the function only works for equally spaced time instants. You may consider reformating your data (using e.g. interpolation) before using toimage.')
end

f = min(f,0.5);
f = max(f,0);

indf = round(2*f*(sply-1)+1);
indt = repmat(round(linspace(1,length(t),splx)),size(A,1),1);
im = accumarray(,A(:),);

indt = indt(1,:);
tt = t(indt);
ff = (0:sply-1)*0.5/sply+1/(4*sply);

end

hahaer 发表于 2008-12-19 22:43

不好意思
根错贴子了
是回复另外一个的:@L
页: [1]
查看完整版本: 求助:关于EMD的toimage.m