laughing 发表于 2007-10-15 23:08

关于HHT中的 toimage 函数

clear
fs=400;
tspan=2;
t=1/fs:1/fs:tspan;
N=length(t);
x1=sin(2*pi*20*t);
x2=0.4*sin(2*pi*40*t+140);
z=x1+x2;
y= linspace(1,2,800);%添加趋势项
z=z+y;
imf=emd(z);
=hhspectrum(imf);
=toimage(A,fa,tt,length(tt));
disp_hhs_lp(im);

如果把最后2行指令改为:
=toimage(A,fa);
disp_hhs_lp(im);

图象就变了,纵坐标频率变了,图中的线条也变了,这是为什么呢?请高手指教指教啊
因为图片太大,所以上传不了

[ 本帖最后由 eight 于 2007-10-15 23:45 编辑 ]

zhangnan3509 发表于 2007-10-15 23:10

回复 #1 laughing 的帖子

这是HHT吧?兄弟,只能明天给你看了,我得下线了。先看看toimage这个函数

[ 本帖最后由 zhangnan3509 于 2007-10-15 23:12 编辑 ]

eight 发表于 2007-10-15 23:26

本帖最后由 VibInfo 于 2016-11-8 14:21 编辑

原帖由 laughing 于 2007-10-15 23:08 发表
clear
fs=400;
tspan=2;
t=1/fs:1/fs:tspan;
N=length(t);
x1=sin(2*pi*20*t);
x2=0.4*sin(2*pi*40*t+140);
z=x1+x2;
y= linspace(1,2,800);%添加趋势项
z=z+y;
imf=emd(z);
=hhspectrum(i ...
自己看看 toimage 的输入参数就知道了

xhm790912 发表于 2007-10-19 14:01

问楼主一个很弱的问题,运行你的程序的时候,运行到命令行
=toimage(A,fa,tt,length(tt));
的时候总是有如下错误提示
??? Error: File: toimage.m Line: 59 Column: 1
This statement is not inside any function.
(It follows the END that terminates the definition of the function "toimage".)

观察 toimage.m,发现toimage.m Line: 59 Column: 1
对应着 命令行 lt=length(t);

请问是什么原因啊

zhlong 发表于 2007-10-19 17:33

回复 #4 xhm790912 的帖子

在程序最末加一个end试试

fengling_335 发表于 2007-11-21 11:01

求助,画红笔的那几句,我看不出是什么意思啊,有谁能帮我解答一下哈
function = toimage(A,f,t,splx,sply)
% = 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 : = toimage(A,f); = toimage(A,f,t); = toimage(A,f,sply);
%             = toimage(A,f,splx,sply); = 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)';

xiamili 发表于 2008-8-13 21:01

同看不懂,高手快指点一下呀,谢!

xiamili 发表于 2008-8-13 21:15

同看不懂啊,请高手指点,谢啦!

cboboc 发表于 2010-3-29 19:55

本帖最后由 VibInfo 于 2016-11-8 14:22 编辑

原帖由 fengling_335 于 2007-11-21 11:01 发表
求助,画红笔的那几句,我看不出是什么意思啊,有谁能帮我解答一下哈
function= toimage(A,f,t,splx,sply)
%= TOIMAGE(A,f,t,splx,sply) transforms a spectrum made
% of 1D functions (e.g., output of "sp ...
请各位高人指点一下,我也是不懂这几句命令的意思?谢谢大家!!!

cboboc 发表于 2010-4-21 16:05

im就是一个矩阵,其中的每个元素位置都有两个数,这两个数分别表示时间和瞬时频率,并且对应这两个数的位置上还有一个a值,im矩阵中的每一个位置上的情况都是如此,所以当im的任意位置上,当t和f相等的时候,就见他们对应的a值相加,也就是与谱图上的相同时间相同频率的幅值相加相吻合。

cboboc 发表于 2010-4-21 16:36

对于toimage函数还是有一点不明白,程序中 ff=floor(f(i,j)*2*(sply-1))+1;
这样求出来的频率是介于0-400之间,是个什么频率呢,这样的频率与画出来的归一化频谱土的频率不一样啊?

cboboc 发表于 2010-5-19 15:54

还是没有看懂

cboboc 发表于 2010-5-23 09:03

本帖最后由 VibInfo 于 2016-11-8 14:22 编辑

原帖由 fengling_335 于 2007-11-21 11:01 发表
求助,画红笔的那几句,我看不出是什么意思啊,有谁能帮我解答一下哈
function= toimage(A,f,t,splx,sply)
%= TOIMAGE(A,f,t,splx,sply) transforms a spectrum made
% of 1D functions (e.g., output of "sp ...
请问大家,我想引用下面这个for循环,但是一点击引用,由于程序太长。就只能显示出程序的起始的那几行内容,要是想引用后面的语句,该怎么操作啊,我找了一下论坛上的内容,也没找到!!


for i = 1:splx
tt(i) = mean(t(floor((i-1)*lt/(splx))+1:floor(i*lt/(splx))));
end

cboboc 发表于 2010-5-23 09:04

不过还是要请教大家,这个for循环中的tt是根据什么来求的?

WJzhengdong 发表于 2010-12-1 16:14

还是解释的不清楚啊,哪位大侠给解释解释啊
页: [1] 2
查看完整版本: 关于HHT中的 toimage 函数