Home > wafo > wsim > duffsim.m

duffsim

PURPOSE ^

Generates a sample path of a harmonic oscillator

SYNOPSIS ^

L = duffsim(T,dt,z,a,b,alf)

DESCRIPTION ^

  DUFFSIM Generates a sample path of a harmonic oscillator  
  
  CALL:  L = duffsim(T,dt,z,a,b,alf); 
  
         L   = a three column matrix with time in the first, the simulated  
               process in the second and the derivative of the simulated  
               process in the third column. 
         T   = the maximum time. 
         dt  = the time step. 
         z,a = parameters in the equation for the oscillator. 
  
    (b,alf are optional imputs with default values -1,2, respectively) 
          The routine generates a sample path of a harmonic oscillator  
          with a nonlinear spring, driven by Gaussian white noise (if alf=2)  
          or alpha-stable white noise (if 0<alf<2). The oscillator is 
   
            L''(t) + 2zL'(t) + bL(t) + aL(t)^3 = sW'(t), 
  
          where  W'(t)  is a white-noise process, s=2*qrt(z)  and  z,b,a  are  
          constants. Important parameter values; 0<z<1, a=0, b=1 normalized 
          linear oscillator (Var(L(t))=Var(L'(t))=1); a=b=0, alf=2 then L'(t) 
          is the Ornstein-Uhlenbeck process; a,z>0, b=-1 Duffing oscilator.   
          The simulation technique is Euler's discretization scheme.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function L = duffsim(T,dt,z,a,b,alf) 
002 % DUFFSIM Generates a sample path of a harmonic oscillator  
003 % 
004 % CALL:  L = duffsim(T,dt,z,a,b,alf); 
005 % 
006 %        L   = a three column matrix with time in the first, the simulated  
007 %              process in the second and the derivative of the simulated  
008 %              process in the third column. 
009 %        T   = the maximum time. 
010 %        dt  = the time step. 
011 %        z,a = parameters in the equation for the oscillator. 
012 % 
013 %   (b,alf are optional imputs with default values -1,2, respectively) 
014 %         The routine generates a sample path of a harmonic oscillator  
015 %         with a nonlinear spring, driven by Gaussian white noise (if alf=2)  
016 %         or alpha-stable white noise (if 0<alf<2). The oscillator is 
017 %  
018 %           L''(t) + 2zL'(t) + bL(t) + aL(t)^3 = sW'(t), 
019 % 
020 %         where  W'(t)  is a white-noise process, s=2*qrt(z)  and  z,b,a  are  
021 %         constants. Important parameter values; 0<z<1, a=0, b=1 normalized 
022 %         linear oscillator (Var(L(t))=Var(L'(t))=1); a=b=0, alf=2 then L'(t) 
023 %         is the Ornstein-Uhlenbeck process; a,z>0, b=-1 Duffing oscilator.   
024 %         The simulation technique is Euler's discretization scheme. 
025  
026 % History:  
027 % Adapted from WAT.  
028 % revised jr: 00.05.16 
029 % - updated final loading 
030 % - updated information 
031  
032 if ( (z<=0) | (z>=1) ) 
033   error('   Parameter z not in (0,1).') 
034 end 
035    
036 if nargin<5 
037    b=-1; 
038 end 
039 if nargin<6 
040    alf=2; 
041 end 
042 if nargin<4 
043    b=1; 
044    a=0; 
045 end 
046 N=(floor(T/dt)+1)*100; 
047  if (N>5000000) 
048      error('Time step  dt  is too small, break.') 
049  end    
050  
051 if exist('simduff.in'), delete simduff.in, end 
052  
053 disp('   Writing data.') 
054 data=[N 0.01*dt z a b alf]; 
055 seed=floor(1e8+rand*899999999); 
056 fprintf('simduff.in','%6.0f %7.5f %7.5f %7.5f %7.5f %7.5f\n',data); 
057 fprintf('simduff.in','%10.0f\n',seed); 
058 disp('   Starting Fortran executable.') 
059 dos([wafoexepath 'simduff.exe']); 
060               
061 disp('   Loading data.') 
062 L=load('out.dat'); 
063 delete simduff.in 
064

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