help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plotting Problem


From: Thomas D. Dean
Subject: Re: Plotting Problem
Date: Sat, 26 Aug 2017 16:43:23 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 08/26/2017 02:09 PM, Dmitri A. Sergatskov wrote:

​It is probably something you did before the plot().
Do you get the same error if you just do
​ plot([1:131073]) in a freshly restarted octave?



    Tom Dean


​Dmitri.
--
​


I attached the script.  It is from a paper:

How to use the FFT and Matlab’s pwelch function
for signal and noise simulations and measurements

Here is the top part of the script down to the first warning.

GNU Octave, version 4.3.0+
Copyright (C) 2016 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> pkg load signal
octave:2> ##
octave:2> TSamp = 1e-6;
octave:3> t = (0:TSamp:2^21*TSamp)';
octave:4> fsig = 440.55;
octave:5> ## Constructed to show some scallop loss
octave:5> asig = 0.8;
octave:6> ## Signal magnitude in V
octave:6> vn = 1/300;
octave:7> ## Total integrated noise in Vrms
octave:7> vin = asig*sin(2*pi*fsig*t)+randn(size(t))*vn;
octave:8> bout = ones(size(vin));
octave:9> qin = 0;
octave:10> regin = vin(1);
octave:11> regout = 0;
octave:12> for k=2:max(size(t));
>   if qin>=0
>     qout=1;
>   else
>     qout=-1;
>   endif
>   bout(k)=qout;
>   qin = regin;
>   regin = vin(k)-qout+qin;
> endfor
octave:13> ## Calculate an 8-times averaged spectrum with pwelch
octave:13> nx = max(size(bout));
octave:14> na = 8;
octave:15> w = blackmanharris(floor(nx/na));
octave:16> [Pxx,f] = pwelch(bout,w,0,[],1/TSamp);
octave:17> ## Calculate the spectrum parameters
octave:17> fbin = f(2)-f(1);
octave:18>
octave:18> CG = sum(w)/(nx/na);
octave:19> NG = sum(w.^2)/(nx/na);
octave:20>
octave:20> ## Calculate the indices of the Signal, harmonics, band edge
octave:20> isig = round(fsig/fbin)+1;
octave:21> ih3 = round(3*fsig/fbin)+1;
octave:22> ih5 = round(5*fsig/fbin)+1;
octave:23> ibw = round(2500/fbin)+1;
octave:24>
octave:24> ## Plot and mark the above
octave:24> printf("Before loglog(f,Pxx)\n")
Before loglog(f,Pxx)
octave:25> printf("Size f:   %d\n", max(size(f)))
Size f:   131073
octave:26> printf("Size Pxx: %d\n", max(size(Pxx)))
Size Pxx: 131073
octave:27> loglog(f,Pxx);
warning: axis: omitting non-positive data in log plot
warning: called from
    __line__ at line 120 column 16
    line at line 56 column 8
    __plt__>__plt2vv__ at line 502 column 10
    __plt__>__plt2__ at line 248 column 14
    __plt__ at line 113 column 17
    loglog at line 60 column 10

Attachment: fft_noise_meas.m
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]