Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9275637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:38:07+00:00 2026-06-18T16:38:07+00:00

Below I present my code how I calculate power spectrum for my signal: Fs=100;

  • 0

Below I present my code how I calculate power spectrum for my signal:

Fs=100;
n = length(x) (in my example always n=160);

whann = window(@hann,n).';
x = whann.*x';

xdft = fft(x);
xdft = (2/length(x))*xdft(1:length(x)/2+1);
xdft = abs(xdft);
xdft=xdft.^2;
freq = 0:Fs/length(x):Fs/2;

Now, I would like to calculate area under power spectrum but only for frequency range 4-6 Hz. The 32 first elements of vector freq look like this:

freq = [0,00    0,28    0,56    0,83    1,11    1,39    1,67    1,94    2,22    2,50    2,78    3,06    3,33    3,61    3,89    4,17    4,44    4,72    5,00    5,28    5,56    5,83    6,11    6,39    6,67    6,94    7,22    7,50    7,78    8,06    8,33]

So, I can find only area between 4,17 Hz- 6,11 Hz.

Could you advice me, how to calculate area under spectrum for specific frequency range (as I mentioned above for example 4-6 Hz)?

Thanks in advance for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:38:08+00:00Added an answer on June 18, 2026 at 4:38 pm

    I would proceed as follows:

    idx = find(freq>=4 & freq<=6);
    
    trapz(freq(idx),spectrum(idx))
    

    If I understood your question right, what stated above should lead you to the results you wanna estimate.

    EDIT

    Since you don’t have spectrum values for freq=4Hz and freq=6Hz, I would suggest to interpolate values like this:

    int_spec = exp(interp1(log(freq),log(spec),log(4:.1:6),'linear','extrap'))
    

    and then call

    trapz(4:.1:6,int_spec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below I present you some code which has completely been butchered by me. $(.gig).hover(function()
I'm using the code below to present the initial View Controller from a Bundle.
I have this code below: package com.example.killall; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import
The code provided below is present in an html file. When opening the file
The Code Below works as expected and when Internet is present in the text
Below is my code present in my application : <input id=input value=Testing /> <a
I'd like to change the code below to present a yes or no option
Below code shows my present implementation , here am creating a toast object and
i use below code - Just try again. - to prevent deadlock. it seems
Can anyone tell me why the code below doesn't seem to prevent the link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.