Home > wafo > spec > oscspec.m

oscspec

PURPOSE ^

Spectral density for a harmonic oscillator

SYNOPSIS ^

S = oscspec(sdata,z,w,s)

DESCRIPTION ^

  OSCSPEC Spectral density for a harmonic oscillator
          driven by white noise
   
  CALL:  S = oscspec(sdata,z,w,s);
 
         S     = the spectral density (structure array)
       sdata = the data vector [wl wu n], where 
  
         wl = lower truncation frequency  (default 4/257)
         wu = upper truncation frequency  (default 4)
         n  = number of evaluation points (default 257)
 
        z,w,s = parameters in the equation (eq. 1) for the oscillator.
                (default z=0.1, w=1, s=1)
         
  Let W  be white noise, then the oscillator X is defined by
   
      X''(t) + 2wz X'(t) + w^2 X(t) = s W(t)          (eq. 1)
    
  Example: 
   data=[0.01 4 275];
   S=oscspec(data,[],2.5);  % Peak frequency at w=2.5

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function S = oscspec(sdata,z,w,s)
002 % OSCSPEC Spectral density for a harmonic oscillator
003 %         driven by white noise
004 %  
005 % CALL:  S = oscspec(sdata,z,w,s);
006 %
007 %        S     = the spectral density (structure array)
008 %      sdata = the data vector [wl wu n], where 
009 % 
010 %        wl = lower truncation frequency  (default 4/257)
011 %        wu = upper truncation frequency  (default 4)
012 %        n  = number of evaluation points (default 257)
013 %
014 %       z,w,s = parameters in the equation (eq. 1) for the oscillator.
015 %               (default z=0.1, w=1, s=1)
016 %        
017 % Let W  be white noise, then the oscillator X is defined by
018 %  
019 %     X''(t) + 2wz X'(t) + w^2 X(t) = s W(t)          (eq. 1)
020 %   
021 % Example: 
022 %  data=[0.01 4 275];
023 %  S=oscspec(data,[],2.5);  % Peak frequency at w=2.5
024 
025 % Tested on: Matlab 5.3
026 % History: 
027 % Correction by PJ 07-Jul-2005
028 %   Changed 'break' to 'return'
029 % revised es 25.05 00 small modifications of help text   
030 % Modified by jr 14.01.2000
031 % - updated check of nargins
032 % Modified by jr 12.01.2000
033 % - new names of variables and parameters
034 % - check of nargins introduced
035 % - updated documentation
036 % Modified by ir 11.01.2000
037 % - structure array introduced
038 % - parameters w,s allowed as input
039 % By Mats Frendahl 1993
040   
041 if nargin<1 | isempty(sdata), sdata=[4/257 4 257];end
042 if nargin<2 | isempty(z), z=0.1;end
043 if nargin<3 | isempty(w), w=1;end
044 if nargin<4 | isempty(s), s=1;end
045 
046 if (z<=0)|(z>=1)
047   disp('   The parameter  z  must be in (0,1). Program will terminate.')
048   return
049 end
050 
051 wl=sdata(1); wu=sdata(2); n=sdata(3); 
052 
053 wv=linspace(0,wu,n);
054 
055 spv=s^2./((w^2-wv.^2).^2+(2*z*w)^2*wv.^2)/2/pi;
056 
057 S=createspec;
058 S.S=spv; 
059 S.w=wv;
060 S.type='freq';
061 S.note='Spectrum, harmonic oscillator';
062 S.S(wv<wl)=0;
063 S.S(1)=0; % must be zero at zero freq since discrete spectrum
064 %S=floor(S*1e5+.5)/1e5;
065 
066 
067

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003