Home > wafo > wsim > disufq.m

# disufq

## PURPOSE

Return difference- and sum-frequency effects.

## SYNOPSIS

[svec, dvec] = disufq(A,w,kw,h,g,nmin,nmax)

## DESCRIPTION

``` DISUFQ  Return difference- and sum-frequency effects.

CALL:  vec         = disufq(A,w,kw,h,g,nmin,nmax)
[svec,dvec] = disufq(A,w,kw,h,g,nmin,nmax)

vec        = svec + dvec = 2nd order frequency component (size m X n).
svec       = 2nd order sum frequency component           (size m X n).
dvec       = 2nd order difference frequency component    (size m X n).
A          = complex amplitudes (size m X n).
w          = vector with angular frequencies (w>=0)
kw         = vector with wavenumbers (kw>=0)
h          = water depth             (h >=0)
g          = constant acceleration of gravity
nmin       = minimum index where abs(A(:,nmin)) is
greater than zero.
nmax       = maximum index where abs(A(:,nmax)) is
greater than zero.

DISUFQ returns the summation of difference frequency and sum
frequency effects in the vector vec = svec + dvec
The 2'nd order contribution to the non-linear wave is then calculated by
a simple 1D Fourier transform, real(FFT(vec)).

Examples:
% Estimate non-linear component
dT = xn(2,1)-xn(1,1);
n  = length(xn);
h  = 10000;
aMax = max(abs(xn(:,2)));
wMax = sqrt(2*gravity/aMax);
A    = ifft(xn(:,2));
w    = linspace(0,pi/dT,n/2);
kw   = w2k(w);
nmax = min(max(find(w<=wMax)));
nmin = 2;
vec  = disufq(A.',w,kw,h,gravity,nmin,nmax);
x2   = real(fft(vec.'));
plot(xn(:,1),xn(:,2),'b',xn(:,1),xn(:,2)-x2,'r',xn(:,1),x2,'g')
legend('nonlinear','approx linear','approx 2nd order comp')

% Simulate non-linear waves
S    = jonswap(5);
xs   = spec2sdat(S,n);
A    = ifft(xs(:,2));
w    = linspace(0,S.w(end),n/2);
kw   = w2k(w);
nmax = min(max(find(w<=wMax)));
nmin = 2;
vec  = disufq(A.',w,kw,h,gravity,nmin,nmax);
x2s  = real(fft(vec.'));
plot(xs(:,1),xs(:,2),'b',xs(:,1),xs(:,2)+x2s,'r',xs(:,1),x2s,'g')
legend('linear','non-linear','2nd order comp')

## CROSS-REFERENCE INFORMATION

This function calls:
 error Display message and abort function.
This function is called by:
 spec2nlsdat Simulates a Randomized 2nd order non-linear wave X(t)

## SOURCE CODE

```001 function [svec, dvec] = disufq(A,w,kw,h,g,nmin,nmax)
002 %DISUFQ  Return difference- and sum-frequency effects.
003 %
004 %  CALL:  vec         = disufq(A,w,kw,h,g,nmin,nmax)
005 %         [svec,dvec] = disufq(A,w,kw,h,g,nmin,nmax)
006 %
007 % vec        = svec + dvec = 2nd order frequency component (size m X n).
008 % svec       = 2nd order sum frequency component           (size m X n).
009 % dvec       = 2nd order difference frequency component    (size m X n).
010 % A          = complex amplitudes (size m X n).
011 % w          = vector with angular frequencies (w>=0)
012 % kw         = vector with wavenumbers (kw>=0)
013 % h          = water depth             (h >=0)
014 % g          = constant acceleration of gravity
015 % nmin       = minimum index where abs(A(:,nmin)) is
016 %              greater than zero.
017 % nmax       = maximum index where abs(A(:,nmax)) is
018 %              greater than zero.
019 %
020 % DISUFQ returns the summation of difference frequency and sum
021 % frequency effects in the vector vec = svec + dvec
022 % The 2'nd order contribution to the non-linear wave is then calculated by
023 % a simple 1D Fourier transform, real(FFT(vec)).
024 %
025 % Examples:
026 %  % Estimate non-linear component
028 % dT = xn(2,1)-xn(1,1);
029 % n  = length(xn);
030 % h  = 10000;
031 % aMax = max(abs(xn(:,2)));
032 % wMax = sqrt(2*gravity/aMax);
033 % A    = ifft(xn(:,2));
034 % w    = linspace(0,pi/dT,n/2);
035 % kw   = w2k(w);
036 % nmax = min(max(find(w<=wMax)));
037 % nmin = 2;
038 % vec  = disufq(A.',w,kw,h,gravity,nmin,nmax);
039 % x2   = real(fft(vec.'));
040 % plot(xn(:,1),xn(:,2),'b',xn(:,1),xn(:,2)-x2,'r',xn(:,1),x2,'g')
041 % legend('nonlinear','approx linear','approx 2nd order comp')
042 %
043 % % Simulate non-linear waves
044 % S    = jonswap(5);
045 % xs   = spec2sdat(S,n);
046 % A    = ifft(xs(:,2));
047 % w    = linspace(0,S.w(end),n/2);
048 % kw   = w2k(w);
049 % nmax = min(max(find(w<=wMax)));
050 % nmin = 2;
051 % vec  = disufq(A.',w,kw,h,gravity,nmin,nmax);
052 % x2s  = real(fft(vec.'));
053 % plot(xs(:,1),xs(:,2),'b',xs(:,1),xs(:,2)+x2s,'r',xs(:,1),x2s,'g')
054 % legend('linear','non-linear','2nd order comp')
055 %
057
058 % Is an internal function to spec2nlsdat
059 % History
060 % This is a MEX-file for MATLAB.
061 % by Per Andreas Brodtkorb 15.08.2001
062 % revised pab 14.03.2002, 01.05.2002 22.07.2002
063
064 error(nargchk(7,7,nargin))
065 disp('This function is only available as a mex-compiled function.')
066 error('Compile disufq.c by using mex -O disufq.c and try again.')
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