[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax befuddlement
From: |
Henry F. Mollet |
Subject: |
Re: Syntax befuddlement |
Date: |
Sat, 27 Dec 2003 11:55:12 -0800 |
User-agent: |
Microsoft-Entourage/10.1.1.2418 |
Thanks for earlier expose on octave for Mac/Fink/DarvinPort.
I've checked below statement with a simple-minded test using a real x and t
and it worked but it may not be a meaningful test:
octave:1> x=rand (1,10)
x =
Columns 1 through 7:
0.925892 0.410042 0.170498 0.240161 0.811388 0.024802 0.997211
Columns 8 through 10:
0.773300 0.687108 0.668670
octave:2> t = [2:9]
t =
2 3 4 5 6 7 8 9
octave:4> fnormhat=0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)/(2*pi)
fnormhat =
0.50000 0.50000 0.50000 0.50000 0.50000 0.50000 0.50000 0.50000
Henry
on 12/26/03 8:14 PM, Joe Koski at address@hidden wrote:
> I'm trying to use a MatLab routine that I found on the net for calculating
> instantaneous local frequency after a Hilbert transform. The hilbert.m
> routine (called from octave-forge) completes successfully. The amplitude of
> the signal is correctly calculated from the results. In attempting to
> calculate frequency and convert the remainder of the MatLab routine to
> octave, I get errors during execution terminating with:
>
> error: invalid vector index = -1
>
> The statement that is being evaluated at the time of the error is
>
> fnormhat=0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)/(2*pi);
>
> where x is a real column vector (representing data) of length 256, and t is
> a real row vector (representing time "instants," but with the first and last
> values truncated) of length 254.
>
> When I try this with the --braindead option, the routine gives no errors,
> but then no results are returned, either. The date on this script is 1994
> and it's currently posted on the web, so it probably really does work in
> MatLab.
>
> As an old Fortran programmer, the statement syntax seems very strange to me.
>
> My questions:
>
> How can one real array with increments (t+1, t-1) be an index for another
> real array (x)? Or does that indicate a functional relationship?
>
> Is this standard octave?
>
> Are there tricks for getting MatLab scripts like this to execute correctly
> in octave?
>
> Alternatively, are there an equivalent octave-forge routines that would
> avoid the problem?
>
> If it would help, I could include more of the routine.
>
> Thanks.
>
> Joe Koski
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------