Computing the phase spectrum of a signalPower Spectral Density from jTransforms DoubleFFT_1DBad Spectrum from Android's FFT-Output (Visualiser)?FFT Pitch Detection - Melody ExtractionjTransforms DoubleFFT_1D first two valuesConfusion in figuring out the relation between actual frequency values and FFT plot indexes in MATLABHow do I obtain Energy spectrum of a signal after FFT in Matlab?phase spectrum of signal wrong generation matlabFourier Transform with MatlabOctave:Incorrect FFT phase spectrumComputing the DFT of an arbitrary signal

Why weren't bootable game disks ever common on the IBM PC?

How were Martello towers supposed to work?

Single word for "refusing to move to next activity unless present one is completed."

How do native German speakers usually express skepticism (using even) about a premise?

Is it OK to leave real names & info visible in business card portfolio?

What does the phrase "head down the rat's hole" mean here?

Why does this potentiometer in an op-amp feedback path cause noise when adjusted?

Is a request to book a business flight ticket for a graduate student an unreasonable one?

Extract string from each line of a file

How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?

Is English unusual in having no second person plural form?

What happens to unproductive professors?

Apex code to find record diff between two dates (to call API only when needed)

Addressing unnecessary daily meetings with manager?

what is mesureable difference between dry basil and fresh?

Concept of the static keyword from the perspective of embedded C

What is this little owl-like bird?

Some interesting calculation puzzle that I made

Misspelling my name on my mathematical publications

What happened to people in unsafe areas during the Blip?

What are the original Russian words for a prostitute?

How can I fix the dull colors I am getting in Ubuntu 19.04 Terminal?

Is anyone advocating the promotion of homosexuality in UK schools?

How can a dictatorship government be beneficial to a dictator in a post-scarcity society?



Computing the phase spectrum of a signal


Power Spectral Density from jTransforms DoubleFFT_1DBad Spectrum from Android's FFT-Output (Visualiser)?FFT Pitch Detection - Melody ExtractionjTransforms DoubleFFT_1D first two valuesConfusion in figuring out the relation between actual frequency values and FFT plot indexes in MATLABHow do I obtain Energy spectrum of a signal after FFT in Matlab?phase spectrum of signal wrong generation matlabFourier Transform with MatlabOctave:Incorrect FFT phase spectrumComputing the DFT of an arbitrary signal






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Using the output from either JTransform, or JWave, how should the phase spectrum be computed?



Do I simply write a similar method, but instead I compute the phase using:
Math.atan2(im / re) * Math.PI * 180?



I've used the following to calculate the magnitude spectrum:



@Override
public void computeSpectrum()

// The spectrum into which we store the data
super.spectrum = new double[signal.getSampledAmplitudes().length >> 1];

// Compute the magnitude spectrum of the signal
double re = 0, im = 0;
for (int bin = 0; bin < spectrum.length - 1; ++bin)
re = super.frequencyDomain[2 * bin];
im = super.frequencyDomain[2 * bin + 1];
super.spectrum[bin] = Math.sqrt(re * re + im * im);











share|improve this question






























    1















    Using the output from either JTransform, or JWave, how should the phase spectrum be computed?



    Do I simply write a similar method, but instead I compute the phase using:
    Math.atan2(im / re) * Math.PI * 180?



    I've used the following to calculate the magnitude spectrum:



    @Override
    public void computeSpectrum()

    // The spectrum into which we store the data
    super.spectrum = new double[signal.getSampledAmplitudes().length >> 1];

    // Compute the magnitude spectrum of the signal
    double re = 0, im = 0;
    for (int bin = 0; bin < spectrum.length - 1; ++bin)
    re = super.frequencyDomain[2 * bin];
    im = super.frequencyDomain[2 * bin + 1];
    super.spectrum[bin] = Math.sqrt(re * re + im * im);











    share|improve this question


























      1












      1








      1








      Using the output from either JTransform, or JWave, how should the phase spectrum be computed?



      Do I simply write a similar method, but instead I compute the phase using:
      Math.atan2(im / re) * Math.PI * 180?



      I've used the following to calculate the magnitude spectrum:



      @Override
      public void computeSpectrum()

      // The spectrum into which we store the data
      super.spectrum = new double[signal.getSampledAmplitudes().length >> 1];

      // Compute the magnitude spectrum of the signal
      double re = 0, im = 0;
      for (int bin = 0; bin < spectrum.length - 1; ++bin)
      re = super.frequencyDomain[2 * bin];
      im = super.frequencyDomain[2 * bin + 1];
      super.spectrum[bin] = Math.sqrt(re * re + im * im);











      share|improve this question
















      Using the output from either JTransform, or JWave, how should the phase spectrum be computed?



      Do I simply write a similar method, but instead I compute the phase using:
      Math.atan2(im / re) * Math.PI * 180?



      I've used the following to calculate the magnitude spectrum:



      @Override
      public void computeSpectrum()

      // The spectrum into which we store the data
      super.spectrum = new double[signal.getSampledAmplitudes().length >> 1];

      // Compute the magnitude spectrum of the signal
      double re = 0, im = 0;
      for (int bin = 0; bin < spectrum.length - 1; ++bin)
      re = super.frequencyDomain[2 * bin];
      im = super.frequencyDomain[2 * bin + 1];
      super.spectrum[bin] = Math.sqrt(re * re + im * im);








      java fft dft






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 0:59









      SleuthEye

      11.2k2 gold badges22 silver badges49 bronze badges




      11.2k2 gold badges22 silver badges49 bronze badges










      asked Mar 25 at 20:29









      DanDan

      235 bronze badges




      235 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Indeed you can compute the phase spectrum in radians with a similar loop as you've used for the magnitude spectrum :



          double re = 0, im = 0;
          for (int bin = 0; bin < spectrum.length - 1; ++bin)
          re = super.frequencyDomain[2 * bin];
          im = super.frequencyDomain[2 * bin + 1];
          super.spectrum[bin] = Math.atan2(im, re);




          If you prefer a result in degrees simply convert the phases with toDegrees()



          ...
          super.spectrum[bin] = Math.toDegrees(Math.atan2(im, re));





          share|improve this answer























          • Will this yield a both positive and negative phase spectrum? Or do I have to 'unwrap' the phase?

            – Dan
            Mar 26 at 9:07











          • As per atan2 documentation: "This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

            – SleuthEye
            Mar 26 at 12:24











          • To get rid of noise in the phase spectrum, would I compute the amplitude (sqrt(re * re * im * im)) beforehand, and discard it it's below a certain threshold, or would I do this directly to the phase value (Math.atan2(im, re))?

            – Dan
            Apr 2 at 9:23











          • If you are trying to isolate sections with a strong coherent signal having a relatively slow varying phase from otherwise weaker noise with randomly fluctuating phase, then the former would be the way to go (ie thresholding based on computed amplitude)

            – SleuthEye
            Apr 3 at 3:26











          • Its to get rid of float / double rounding issues.

            – Dan
            Apr 3 at 5:18










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345939%2fcomputing-the-phase-spectrum-of-a-signal%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Indeed you can compute the phase spectrum in radians with a similar loop as you've used for the magnitude spectrum :



          double re = 0, im = 0;
          for (int bin = 0; bin < spectrum.length - 1; ++bin)
          re = super.frequencyDomain[2 * bin];
          im = super.frequencyDomain[2 * bin + 1];
          super.spectrum[bin] = Math.atan2(im, re);




          If you prefer a result in degrees simply convert the phases with toDegrees()



          ...
          super.spectrum[bin] = Math.toDegrees(Math.atan2(im, re));





          share|improve this answer























          • Will this yield a both positive and negative phase spectrum? Or do I have to 'unwrap' the phase?

            – Dan
            Mar 26 at 9:07











          • As per atan2 documentation: "This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

            – SleuthEye
            Mar 26 at 12:24











          • To get rid of noise in the phase spectrum, would I compute the amplitude (sqrt(re * re * im * im)) beforehand, and discard it it's below a certain threshold, or would I do this directly to the phase value (Math.atan2(im, re))?

            – Dan
            Apr 2 at 9:23











          • If you are trying to isolate sections with a strong coherent signal having a relatively slow varying phase from otherwise weaker noise with randomly fluctuating phase, then the former would be the way to go (ie thresholding based on computed amplitude)

            – SleuthEye
            Apr 3 at 3:26











          • Its to get rid of float / double rounding issues.

            – Dan
            Apr 3 at 5:18















          0














          Indeed you can compute the phase spectrum in radians with a similar loop as you've used for the magnitude spectrum :



          double re = 0, im = 0;
          for (int bin = 0; bin < spectrum.length - 1; ++bin)
          re = super.frequencyDomain[2 * bin];
          im = super.frequencyDomain[2 * bin + 1];
          super.spectrum[bin] = Math.atan2(im, re);




          If you prefer a result in degrees simply convert the phases with toDegrees()



          ...
          super.spectrum[bin] = Math.toDegrees(Math.atan2(im, re));





          share|improve this answer























          • Will this yield a both positive and negative phase spectrum? Or do I have to 'unwrap' the phase?

            – Dan
            Mar 26 at 9:07











          • As per atan2 documentation: "This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

            – SleuthEye
            Mar 26 at 12:24











          • To get rid of noise in the phase spectrum, would I compute the amplitude (sqrt(re * re * im * im)) beforehand, and discard it it's below a certain threshold, or would I do this directly to the phase value (Math.atan2(im, re))?

            – Dan
            Apr 2 at 9:23











          • If you are trying to isolate sections with a strong coherent signal having a relatively slow varying phase from otherwise weaker noise with randomly fluctuating phase, then the former would be the way to go (ie thresholding based on computed amplitude)

            – SleuthEye
            Apr 3 at 3:26











          • Its to get rid of float / double rounding issues.

            – Dan
            Apr 3 at 5:18













          0












          0








          0







          Indeed you can compute the phase spectrum in radians with a similar loop as you've used for the magnitude spectrum :



          double re = 0, im = 0;
          for (int bin = 0; bin < spectrum.length - 1; ++bin)
          re = super.frequencyDomain[2 * bin];
          im = super.frequencyDomain[2 * bin + 1];
          super.spectrum[bin] = Math.atan2(im, re);




          If you prefer a result in degrees simply convert the phases with toDegrees()



          ...
          super.spectrum[bin] = Math.toDegrees(Math.atan2(im, re));





          share|improve this answer













          Indeed you can compute the phase spectrum in radians with a similar loop as you've used for the magnitude spectrum :



          double re = 0, im = 0;
          for (int bin = 0; bin < spectrum.length - 1; ++bin)
          re = super.frequencyDomain[2 * bin];
          im = super.frequencyDomain[2 * bin + 1];
          super.spectrum[bin] = Math.atan2(im, re);




          If you prefer a result in degrees simply convert the phases with toDegrees()



          ...
          super.spectrum[bin] = Math.toDegrees(Math.atan2(im, re));






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 0:57









          SleuthEyeSleuthEye

          11.2k2 gold badges22 silver badges49 bronze badges




          11.2k2 gold badges22 silver badges49 bronze badges












          • Will this yield a both positive and negative phase spectrum? Or do I have to 'unwrap' the phase?

            – Dan
            Mar 26 at 9:07











          • As per atan2 documentation: "This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

            – SleuthEye
            Mar 26 at 12:24











          • To get rid of noise in the phase spectrum, would I compute the amplitude (sqrt(re * re * im * im)) beforehand, and discard it it's below a certain threshold, or would I do this directly to the phase value (Math.atan2(im, re))?

            – Dan
            Apr 2 at 9:23











          • If you are trying to isolate sections with a strong coherent signal having a relatively slow varying phase from otherwise weaker noise with randomly fluctuating phase, then the former would be the way to go (ie thresholding based on computed amplitude)

            – SleuthEye
            Apr 3 at 3:26











          • Its to get rid of float / double rounding issues.

            – Dan
            Apr 3 at 5:18

















          • Will this yield a both positive and negative phase spectrum? Or do I have to 'unwrap' the phase?

            – Dan
            Mar 26 at 9:07











          • As per atan2 documentation: "This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

            – SleuthEye
            Mar 26 at 12:24











          • To get rid of noise in the phase spectrum, would I compute the amplitude (sqrt(re * re * im * im)) beforehand, and discard it it's below a certain threshold, or would I do this directly to the phase value (Math.atan2(im, re))?

            – Dan
            Apr 2 at 9:23











          • If you are trying to isolate sections with a strong coherent signal having a relatively slow varying phase from otherwise weaker noise with randomly fluctuating phase, then the former would be the way to go (ie thresholding based on computed amplitude)

            – SleuthEye
            Apr 3 at 3:26











          • Its to get rid of float / double rounding issues.

            – Dan
            Apr 3 at 5:18
















          Will this yield a both positive and negative phase spectrum? Or do I have to 'unwrap' the phase?

          – Dan
          Mar 26 at 9:07





          Will this yield a both positive and negative phase spectrum? Or do I have to 'unwrap' the phase?

          – Dan
          Mar 26 at 9:07













          As per atan2 documentation: "This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

          – SleuthEye
          Mar 26 at 12:24





          As per atan2 documentation: "This method computes the phase theta by computing an arc tangent of y/x in the range of -pi to pi."

          – SleuthEye
          Mar 26 at 12:24













          To get rid of noise in the phase spectrum, would I compute the amplitude (sqrt(re * re * im * im)) beforehand, and discard it it's below a certain threshold, or would I do this directly to the phase value (Math.atan2(im, re))?

          – Dan
          Apr 2 at 9:23





          To get rid of noise in the phase spectrum, would I compute the amplitude (sqrt(re * re * im * im)) beforehand, and discard it it's below a certain threshold, or would I do this directly to the phase value (Math.atan2(im, re))?

          – Dan
          Apr 2 at 9:23













          If you are trying to isolate sections with a strong coherent signal having a relatively slow varying phase from otherwise weaker noise with randomly fluctuating phase, then the former would be the way to go (ie thresholding based on computed amplitude)

          – SleuthEye
          Apr 3 at 3:26





          If you are trying to isolate sections with a strong coherent signal having a relatively slow varying phase from otherwise weaker noise with randomly fluctuating phase, then the former would be the way to go (ie thresholding based on computed amplitude)

          – SleuthEye
          Apr 3 at 3:26













          Its to get rid of float / double rounding issues.

          – Dan
          Apr 3 at 5:18





          Its to get rid of float / double rounding issues.

          – Dan
          Apr 3 at 5:18








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345939%2fcomputing-the-phase-spectrum-of-a-signal%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해