help-octave
[Top][All Lists]
Advanced

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

Re: Electrical signal analisis


From: Jaime Alberto Silva
Subject: Re: Electrical signal analisis
Date: Mon, 23 Aug 2004 14:19:25 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5

Thanks a lot for your help but those libraries are for signals that

change frecuency in time. I need simpler tools for signals that keep the same frecuency all the time. For the moment I'll use the functions attached to find the delay between signals and the fft to obtain the fundamental frecuency (with max()).

Joe Koski wrote:

on 8/21/04 11:10 AM, robert Macy at address@hidden wrote:

Group (and Joe)

http://iut-saint-nazaire.univ-nantes.fr/~auger/tftb.html
The URL at France didn't seem active.  Any new location for
same information?

    - Robert -

Robert,

I just tried and downloaded the full UNIX tftb.tar.gz version from the
mirror site without any problems. I did not try the .zip version or the main
site.

Joe Koski

On Wed, 18 Aug 2004 10:30:45 -0600
Joe Koski <address@hidden> wrote:
There are two more signal processing libraries (besides
those with octave
and octave-forge) of which you should also be aware, and
possibly install.
The URLs for them are

http://www-stat.stanford.edu/~wavelab/
http://wiki.octave.org/wiki.pl?WavelabOnOctave

And
http://iut-saint-nazaire.univ-nantes.fr/~auger/tftb.html
http://perso.ens-lyon.fr/patrick.flandrin/emd.html

The latter has a routine extr.m that finds all local
maxima and minima of a
time (or frequency) series.

For help with octave and octave-forge signal processing
routines, check the
information at
http://octave.sourceforge.net/index/index.html

There is a wealth of good signal processing software
available. Good luck.

Joe Koski

on 8/17/04 7:10 PM, Jaime Alberto Silva at
address@hidden wrote:

I'm new in the use of this tools (octave, mathlab,
etc.) and since I'm a
full time Linux user I am using octave.

Currently, I'm trying to do some electrical signal
analysis and I will
like to know if there are predefined functions for some
calculations or
how can I do them with octave:

1. Frecuency: I have founded in the "Signal Processing"
section the fft
function, OK it is great but how do I find the
frecuencies from the
returned vector. I know that using the max function I
can find the
fundamental frecuency like this:

# Create the signal:
octave:190> t= [0: 1/2000: 5 - 1/2000];
octave:191> sint= sin(2*pi*60*t);
# Transform the signal:
octave:192> ft= abs(fft(sint));
# Find the position of the max value of the
transformation:
octave:193> [val, idx]= max(ft);
# Use the sampling rate to obtain the fundamental
frecuency:
octave:194> fund_frec= 2000 * idx/ length(ft)
fund_frec = 60.200
octave:195>

But how can I find the other frecuencies in case it has
more components
like in
f= sin x + 0.5 sin 3x + 2 sin 10x ?

2. Phasors: If I have 2 signals like v1 an v2 how do I
find the angle of
v2 with respect of v1. I mean if v1= sin (t) and v2=
sin (t + 15°) and I
have sampled those signals in time, how do I find that
v2 is delayed 15
degrees with respect to v1? taking in account that v2
samples where
taken in different times to v1 samples like this: v1(1)
was taken at T0,
v2(1) was taken at T0 + dT. And, of course, you know
the value of dT.
3. Electric Power: If I have sampled the signals of
voltage (V) and
current (I) are there any tools that l can use to
obtain the active (P)
and reactive (Q) power, the S vector angle, etc. ? I
know that I can
multiply the signals but, you know if there are tools
for that why do it
again.

Thanks in advance for any help you can bring me.



--
Jaime Alberto Silva Colorado

function d = signal_delay (signal1, signal2, t)

                                % d = SIGNAL_DELAY (sig1, sig2, t) finds
                                % the delaying of sig2 with respect to
                                % sig1.
%
                                % Inputs: 
                                % - sig1: reference sinusoidal signal.
                                % - sig2: delayed sinusoidal signal.
%
                                % Outputs:
                                % - d: delay of sig2 with respect to sig1.

  if (nargin < 2)
                                % error
  end
  if (nargin == 2)
    t= 1:length(signal1);
  end

  sig1= [];
  sig2= [];
  s= size(signal1);
  if (s(1,1) != 1)
    sig1= signal1';
  else
    sig1= signal1;
  end
  s= size(signal2);
  if (s(1,1) != 1)
    sig2= signal2';
  else
    sig2= signal2;
  end
  

  iz1= zero_crossings (sig1,t);
  iz2= zero_crossings (sig2,t);
  dif1= diff (sig1);
  dif2= diff (sig2);
  iz2r= [];
  if (dif1(iz1(1)) < 0)
    for i = iz2
      if dif2(i) < 0
        iz2r= i;
        break;
      end
    end
  else
    for i = iz2
      if dif2(i) >= 0
        iz2r= i;
        break;
      end
    end
  end

    
  lx= iz1(1); # x coord at the left of the cross
  ly= sig1(lx); # y coord at the left of the cross
  rx= lx + 1; # x coord at the rigth of the cross
  ry= sig1(rx); # y coord at the rigth of the cross
  m= (ry - ly)/(rx - lx);
  b= ly - m * lx; # y = mx + b => b= y - mx
  t1= -1 * b / m; # y= mx + b, y= 0 => x = -b/m

#   disp ("x1:"), disp (lx);
#   disp ("y1:"), disp(ly);
#   disp ("y'1:"), disp(dif1(lx));

  lx= iz2r; # x coord at the left of the cross
  ly= sig2(lx); # y coord at the left of the cross
  rx= lx + 1; # x coord at the rigth of the cross
  ry= sig2(rx); # y coord at the rigth of the cross
  m= (ry - ly)/(rx - lx);
  b= ly - m * lx; # y = mx + b => b= y - mx
  t2= -1 * b / m; # y= mx + b, y= 0 => x = -b/m

#   disp ("x2:"), disp (lx);
#   disp ("y2:"), disp(ly);
#   disp ("y'2:"), disp(dif2(lx));

  d= t2 - t1;
end

  
  
function indzer = zero_crossings (data,t);

% indzer = ZERO_CROSSINGS (x,t) finds zero-crossings
%
% inputs : - x : analyzed signal
%          - t (optional) : sampling times, default 1:length(x)
%
% outputs : - indzer = indices of zero-crossings

  if(nargin==1)
    t=1:length(x);
  end
  m = length(t);
  x= data(t(1):t(m));

  x1= x(1:m-1);
  x2= x(2:m);
  indzer = find(x1.*x2<0);

  if any(x == 0)
    iz = find( x==0 );
    indz = [];
    if any(diff(iz)==1)
      zer = x == 0;
      dz = diff([0 zer 0]);
      debz = find(dz == 1);
      finz = find(dz == -1)-1;
      indz = round((debz+finz)/2);
    else
      indz = iz;
    end
    indzer = sort([indzer indz]);
  end
end


reply via email to

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