Code Monkey home page Code Monkey logo

Comments (4)

yrtan avatar yrtan commented on July 20, 2024

Tried the default example from calcnaff and got the same phases each time. Also tried it on some BPM data. I couldn't repeat the problem for AT2.0. nafflib.c revision date 25/7/2017.

You can use it for just real signals and the phases be also be correct (taking only the positive frequencies). However for the amplitude you have to sum the positive and negative frequency amplitudes to get it right. Or you can simply multiply by a factor of 2 if the frequency is not zero or fs/2.

from at.

lnadolski avatar lnadolski commented on July 20, 2024

Dear @carmignani,
I cannot reproduced your bug.

If you run the nafflib algorithm with a real signal, its works well for me.
This is a simple example :

t = linspace(1,2pi20,1000);

[frequency amplitude phase] = nafflib(sin(t),sin(t)0, 1, 5, 1)
*** NAFF results ***
NFS = 2
AMPL= 4.207309e-01+i
2.701499e-01 abs(AMPL)= 4.999955e-01 arg(AMPL)= 5.707992e-01 FREQ=-1.247885e-01
AMPL= 4.207355e-01+i*-2.701512e-01 abs(AMPL)= 5.000000e-01 arg(AMPL)=-5.707963e-01 FREQ= 1.247885e-01

The phase is stable and the amplitude of each harmonic is 0.5 as expected.

from at.

lnadolski avatar lnadolski commented on July 20, 2024

Nevertheless, I suspect something wrong the in the c-library, since sometimes, the function returns NaNs for valid input signal.
If I rerun again the same command with the same input argument the results is then fine.
I suspect something not properly defined with the dynamic memory allocation in the code.

I need to run the code in debugger to understand. This is quite annoying and time consuming to debug.
Any advice is very welcome.

from at.

carmignani avatar carmignani commented on July 20, 2024

I get exactly the same output running the example you wrote, but if I run it many times sometimes I get nans.
I also suspect there are some problems in the dynamic memory allocation in the C code.

from at.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.