|
From: Dmitri A. S. <das...@gm...> - 2007-06-04 16:41:16
|
On 6/4/07, Peter Vernon Lanspeary <pv...@me...> wrote: > Hi Dmitri, > > On Fri, Jun 01, 2007 at 03:38:06PM -0500, Dmitri A. Sergatskov wrote: > > The new version of pwelch (by Peter V. Lanspeary) seems to have problem > > parsing argument list. E.g. "demo pwelch" would fail: > > > > pwelch example 1: failed > > error: pwelch: arg 3 (overlap) must be real from 0 to 0.950000 > > > > apparently on the line pwelch(x,[],[],[],[],0.9); > > "demo pwelch" works for me. > "pwelch(x,[],[],[],[],0.9)" gives 90% confidence limits, as expected. > To obtain "error: pwelch: arg 3 (overlap) must be real from 0 to 0.950000" > I need to do something like "pwelch(x,[],0.99)". > I guess I forgot to CC my reply to David to the list. I was having the problem because, apparently, I had two "pwelch.m" in my path. For some reason octave picked up demo code from the wrong file (while "which pwelch", "help pwelch" , "type pwelch", etc... all looked at the correct one). > > It also gets easily confused when pwelch called with two channels, e.g.: > > > > pwelch(x, y, [], [], [], 1000, [], [], "mean", [], "trans") > > error: pwelch: can give confidence interval for x power spectrum only > > error: evaluating if command near line 507, column 3 > > error: evaluating if command near line 279, column 1 > > error: called from `pwelch' in file > > `/usr/share/octave/site/m/octave-forge/signal/pwelch.m' > > > > In fact it appears that i cannot specify any parameter between > > "sampling frequency" and "result" parameters... > > I have added an explanation of your problem in the documentation string: > > %% [spectra,Pxx_ci,freq] = pwelch(x,window,overlap,Nfft,Fs,conf, > %% range,plot_type,detrend,sloppy) > %% [spectra,Pxx_ci,freq] = pwelch(x,y,window,overlap,Nfft,Fs,conf, > %% range,plot_type,detrend,sloppy,results) > %% Estimates confidence intervals for the spectral density. > %% See Hint (7) below for compatibility options. Confidence level "conf" > %% is the 6th or 7th numeric argument. If "results" control-string > %% arguments are used, one of them must be "power" when the "conf" > %% argument is present; pwelch can estimate confidence intervals only for > %% the power spectrum of the "x" data. It does not know how to estimate > %% confidence intervals of the cross-power spectrum, transfer function or > %% coherence; if you can suggest a good method, please send a bug report. > > and I have committed the changes. > > pwelch(x, y, [], [], [], 1000, [], [], "mean", [], "trans", "power" ) > returns with > a) the 95% confidence interval for the power spectral density of "x", and > b) the transfer function without a confidence interval. > > > Sorry, I do not have a patch, the source of pwelch.m is too > > unwieldy for me. > > That's fine. I think that what you apparently found was normal > (expected) behaviour, not a bug. > The thing that confused me here is that if i used [] in place for string arguments, I get an error. E.g: octave:1> x=rand(1,1024); y=x; octave:2> pwelch(x,y,[],[],[],100,[],[],[],"mean", [], "trans") error: pwelch: can give confidence interval for x power spectrum only error: evaluating if command near line 507, column 3 error: evaluating if command near line 279, column 1 error: called from `pwelch' in file `/usr/share/octave/site/m/octave-forge/signal/pwelch.m' octave:2> If I call it instead like that: pwelch(x,y,[],[],[],100,"mean", "trans") it would work fine. I guess the issue is that pwelch for (say) "trans" would fail even with the defaul value for "range". In my opinion it would be better to issue a warning: "Do not know how to estimate the confifdence intervals of the cross-power spectrum. Parameter ignored" and, if possible, have default value for "conf" is [] (?!) > Thanks, > Peter > Thank you for your help. Sincerely, Dmitri. -- |