help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hilbert transform y = hilbert(x,n)


From: John B. Thoo
Subject: Re: Hilbert transform y = hilbert(x,n)
Date: Tue, 9 Jun 2009 20:49:34 -0700


On Jun 9, 2009, at 11:35 AM, Dmitri A. Sergatskov wrote:

On Tue, Jun 9, 2009 at 9:35 AM, John B. Thoo<address@hidden> wrote:
Hello, everyone.

A friend sent me some code he had written for the "dark side."  When
I tried to execute it in Octave, I got the error

error: `hilbert' undefined near line 11 column 8
error: evaluating assignment expression near line 11, column 6
error: called from `psidot' in file `/Users/jbthoo/Desktop/
NumMethPractice/BurgersHilbert/psidot.m'
error: called from `rk_step' in file `/Users/jbthoo/Desktop/
NumMethPractice/BurgersHilbert/rk_step.m'
error: evaluating for command near line 93, column 5
error: evaluating for command near line 91, column 1
error: near line 101 of file `/Users/jbthoo/Desktop/NumMethPractice/
BurgersHilbert/run_amp.m'
octave-3.0.5:4>

When I looked in the file "psidot.m", I saw near the beginning the line

hpsi = hilbert(psi,lx);

so I googled "octave hilbert".  This led me to two definitions of
"hilbert":

<http://sccn.ucsd.edu/pipermail/eeglablist/2006/001257.html>
<http://www.nabble.com/Hilbert-transform-m-file-contribution-
td9238169.html>

However, both of them define

y = hilbert(x)

of one argument instead of two as called in "psidot.m".

hilbert is part of the octave-forge signal-1.0.8 package :



octave:1> help hilbert
 -- Function File: H = hilbert (F,N,DIM)
     Analytic extension of real valued signal

     `H=hilbert(F)' computes the extension of the real valued signal F
     to an analytic signal. If F is a matrix, the transformation is
     applied to each column. For N-D arrays, the transformation is
     applied to the first non-singleton dimension.

     `real(H)' contains the original signal F.  `imag(H)' contains the
     Hilbert transform of F.

     `hilbert(F,N)' does the same using a length N Hilbert transform.
     The result will also have length N.

     `hilbert(F,[],DIM)' or `hilbert(F,N,DIM)' does the same along
     dimension dim.

/usr/share/octave/packages/signal-1.0.8/hilbert.m

Additional help for built-in functions and operators is
available in the on-line version of the manual.  Use the command
`doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the address@hidden
mailing list.
octave:2>


How can I modify either of the two definitions that google returned
so that I can execute my friend's code?

Thanks.

---John.

Hope that helps,

Dmitri.

Hi, Dimitri. Thanks for the tip. I duly installed "signal-1.0.10.tar.gz" (after installing the dependencies "miscellaneous-1.0.9.tar.gz" and "optim-1.0.6.tar.gz"). Then I ran "run_amp" again. Now I get this error:

error: HILBERT only works for real-valued signals.
error: evaluating if command near line 47, column 3
error: called from `hilbert' in file `/Users/jbthoo/octave/ signal-1.0.10/hilbert.m'
error: evaluating assignment expression near line 11, column 6
error: called from `psidot' in file `/Users/jbthoo/Desktop/ NumMethPractice/BurgersHilbert/psidot.m' error: called from `rk_step' in file `/Users/jbthoo/Desktop/ NumMethPractice/BurgersHilbert/rk_step.m'
error: evaluating for command near line 93, column 5
error: evaluating for command near line 91, column 1
error: near line 101 of file `/Users/jbthoo/Desktop/NumMethPractice/ BurgersHilbert/run_amp.m'
octave-3.0.5:10>

so I edited the following line in "psidot.m"

hpsi = hilbert(psi,lx);

to

hpsi = hilbert(real(psi),lx);

and it runs without any error complaints. Yea! :-) Now I only hope that (inserting "real") was the right thing to do. Was it?

BTW, on the "dark side" I don't get the complaint that "HILBERT only works for real-valued signal"; instead, I get the warnings:

Warning: HILBERT ignores imaginary part of input
> In hilbert at 39
  In psidot at 11
  In rk_step at 10
  In run_amp at 94

but the program continues.

Thanks again.

---John.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]