How to integrate Pwelch with Matlab

In summary, you are trying to apply an integration using the power spectral density calculated with the pwelch method in Matlab. However, since Pxx is a matrix, you need to use a loop to iterate through each element and calculate the integral using the trapz function. The result will be stored in a vector called Z.
  • #1
windsea
1
0
Dears,

Please help hem in order to resolve this problem.

I estimated an power spectral density using welch method with Matlab program (Pxx).

Now, I want apply this integration

m[n] := Integral from f=0.0001 to f=0.001 over S(f) * f ^ n . In my case I think that m[n] := Integral from f=0.0001 to f=0.001 over Pxx(f) * f ^ n !

After several tests I did not succeed to make this integration.

Please help me in view to intruduce this application within my code:

Code:
load wave.dat
x=wave(:,1);
fs=0.011;
u = length(x);
[Pxx,f] = pwelch(x,800,400,u,fs)
pwelch(x,800,400,u,fs)
f=0.00001 :0.0000.1/100 :0.0001 ;n=0
Z=trapz(f,Pxx)*f^n

I send also the continuous equation in the attached file
Thank you in advance

Windsea
 

Attachments

  • integrale.JPG
    integrale.JPG
    2 KB · Views: 537
Physics news on Phys.org
  • #2
Answer: The code you provided assumes that Pxx is a vector, whereas Pxx is actually a matrix since it was created by pwelch. You need to index each element of Pxx as Pxx(i) when calculating the integral. Therefore, you would need to use a loop to iterate through each element of Pxx and calculate the integral for each one using the trapz function. Here is an example of what the code would look like:load wave.datx=wave(:,1);fs=0.011;u = length(x);[Pxx,f] = pwelch(x,800,400,u,fs)pwelch(x,800,400,u,fs)f=0.00001 :0.0000.1/100 :0.0001 ;n=0Z = zeros(length(Pxx),1);for i = 1:length(Pxx) Z(i) = trapz(f,Pxx(i))*f^n; endThe vector Z will contain the result of the integration.
 

1. How do I import Pwelch into Matlab?

To import Pwelch into Matlab, you can use the "import" function with the name of the Pwelch file, or you can add the Pwelch folder to your Matlab path.

2. How do I use Pwelch in my Matlab code?

To use Pwelch in your Matlab code, you can call the function by its name and pass in your data as arguments. You can also specify any additional parameters, such as window type or sampling frequency, in the function call.

3. How do I interpret the output of Pwelch?

The output of Pwelch is a power spectral density estimate, which represents the distribution of power in a signal over different frequencies. The y-axis of the plot represents the power values, while the x-axis represents the corresponding frequencies. Higher peaks on the plot indicate higher power at those frequencies.

4. Can I use Pwelch for non-stationary signals?

Yes, Pwelch can be used for both stationary and non-stationary signals. However, for non-stationary signals, it is recommended to use a shorter window length and overlap to capture changes in the signal over time.

5. Are there any alternatives to using Pwelch in Matlab?

Yes, there are other functions in Matlab that can also perform spectral analysis, such as the "fft" and "periodogram" functions. However, Pwelch is specifically designed for power spectral density estimation and may provide more accurate results for certain types of signals.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
992
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
16
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
958
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
Back
Top