| MATLAB Central > MATLAB Newsreader > PSD and windowing function |
|
|
|
I have a query concerning PSD. I am trying to use MATLAB for this, but the dominant frequencies I am getting are very scattered and I need to incorporate a windowing function to smooth out all the peaks. I would like to incorporate to begin with a simple cosine windowing function of the form w(kdt)=cos (Pi*kdt/2 *t). where dt is resolution of the time delay. I am unsure how to put this into my program, and this is simpler than the window function inbuilt in Matlab. The program is as follows (H1 in this example has 30000 data points): |
|
On Aug 30, 9:50 am, "Safa " <enxs...@nottingham.ac.uk> wrote: |
|
On Aug 30, 1:04 am, TideMan <mul...@gmail.com> wrote: |
|
Rune Allnor <allnor@tele.ntnu.no> wrote in message <b4b62db2-03af-4a5d-9e48-5317a5a72b2f@n3g2000yqb.googlegroups.com>... |
|
On Aug 29, 5:50 pm, "Safa " <enxs...@nottingham.ac.uk> wrote: |
|
On Aug 29, 5:50 pm, "Safa " <enxs...@nottingham.ac.uk> wrote: |
|
Thanks very much for your comments, although there are what appears two identical replies? If I take on board your suggestions, is the new program as per below? It was a little difficult to follow, as there are tabs everywhere, so I tried to tidy it up. One query about the windowing equation. Appreciate your help. |
|
Subject: PSD and windowing function From: Walter Roberson Date: 30 Aug, 2010 21:54:20 Message: 8 of 23 |
|
On 10-08-30 11:22 AM, Greg Heath wrote: |
|
On Aug 30, 1:31 pm, "Safa " <enxs...@nottingham.ac.uk> wrote: |
|
Sorry I was away on a conference and had to leave this for a few weeks. I am trying to follow your latest comments, and I am even more confused than before. You seem also to be contradicting your own code e.g. H1 = H1-mean(H1); One minute you say put it in, and next minute take it out. Please can I ask you for a HUGE favour. Could you kindly write your whole suggested program in one paragraph with no comments, and I will try it on my data? I will report back here on the results I get. I have an Excel macro that I can compare it with. Thanks for your assistance. |
|
"Safa " <enxss10@nottingham.ac.uk> wrote in message <i80f14$3ts$1@fred.mathworks.com>... |
|
On Sep 29, 6:36 pm, "Safa " <enxs...@nottingham.ac.uk> wrote: |
|
Wayne may I say that is a fantastic example you’ve given, and it illustrates precisely my problem and what I am trying to do!! Yes I have the signal processing toolbox, although I must admit I haven't used it. In your example, you can see how much smoother the PSD is when you apply a window function. The question how can I apply a simple cosine window function using your approach? Is there a way to define it manually? I have been trying to do this with Greg, and it has been a painful exercise. While I highly appreciate Greg’s wonderful efforts, it is getting into fairly advanced signal processing techniques. But I like Greg’s methodology to get me thinking and I will keep trying, until I get my head round everything he has suggested. I have a lot of data to process and it is a nightmare to do this in Excel. I need a more automated process this is why I turned to |
|
"Safa " <enxss10@nottingham.ac.uk> wrote in message <i83aqr$e7r$1@fred.mathworks.com>... |
|
Wayne, Thank you very much for your help and I agree with you, the Welch spectrum is really powerful, I am amazed how it is filtering the PSD. If I want to automate your program and run say 10 data sets, how can I get Matlab to plot all 10 PSDs on one sheet (separate graphs), and to also generate a report giving me the maximum frequency for each PSD? For the code I wrote below, in the workspace, it only saves data for the last run. I've worked out how to do the PSD manually using the signal processing toolbox, which is a really useful facility to have and having played with all the windows, I found Hanning would be a good choice. I’m working with a file that contains both numbers and words, and matlab does not like that at all so need to filter the data. If you have time, I would be interested in the “user defined” command, for a cosine window of the form w(kdt)=cos |
|
"Safa " <enxss10@nottingham.ac.uk> wrote in message <i8ak18$n09$1@fred.mathworks.com>... |
|
"Safa " <enxss10@nottingham.ac.uk> wrote in message <i5ekmr$4u$1@fred.mathworks.com>... |
|
Ok I am baffled again, I tried using the welch method, and it keeps giving me the same maximum frequency for all different runs. It is not picking up local maximum frequencies. So I have gone back to my initial program, and incorporated what Greg has suggested. It works. However, I have one final query about the maximum frequency it reads. For one run with 30000 data points (30 seconds of data @ Fs=1000Hz), the matrix for frequency = (0:df:Fs/2)'; is 15001xdouble and starts at zero. The matrix for fr = (1/dt)*(1:15000)/N is 15000xdouble and doesn't start at zero. The matrix for Pyy interval is 15000xdouble. In the trial run, it says it is picking out row 29 as maximum frequency. Is it reading the same value in the same row for both Pyy interval and frequency matrices? Why are the two matrices not the same size and do we need to adjust them to make them same size? Appreciate your help |
|
Ok I will make my question simpler. I've tidied up the code as follows: |
|
I apologise slightly corrected code (I must ignore Y(1), it is so much higher than the other values, so taken on board your suggestion to take out mean value for Hl) |
|
Would really appreciate some help with the above program. I think the bulk of the program is now OK, I just need clarification to a couple of lines in the code. Thanks in anticipation! |
|
On Oct 5, 8:20 pm, "Safa " <enxs...@nottingham.ac.uk> wrote: |
|
On Oct 18, 12:10 am, Greg Heath <he...@alumni.brown.edu> wrote: |
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
| Tag Activity for This Thread | ||
|---|---|---|
| Tag | Applied By | Date/Time |
| erb | Anson Ting | 2 Nov, 2010 10:05:02 |
| psd | Safa | 29 Aug, 2010 17:54:14 |
