Home > wafo > multidim > private > normspfn.m

# normspfn

## SYNOPSIS

DS = normspfn(DS,thetai)

## DESCRIPTION

``` NORMSPFN normalizes the spreading function

CALL: DS = normspfn(DS,thetai)

DS     = spreading function size nt x nf
thetai = angles size nt x 1

(it also truncate negative values to zero)```

## CROSS-REFERENCE INFORMATION

This function calls:
 trapz Trapezoidal numerical integration.
This function is called by:
 emem Extended Maximum Entropy Method imlm Iterated maximum likelihood method for estimating the directional distribution mem maximum entropy method for estimating the directional distribution mlm maximum likelihood method for estimating the directional distribution

## SOURCE CODE

```001 function DS = normspfn(DS,thetai)
002 %NORMSPFN normalizes the spreading function
003 %
004 %  CALL: DS = normspfn(DS,thetai)
005 %
006 % DS     = spreading function size nt x nf
007 % thetai = angles size nt x 1
008 %
009 % (it also truncate negative values to zero)
010 %
011
012 nt  = length(thetai);
013 ind = find(DS<0 | isnan(DS));
014 if any(ind),
015 %  disp('isnan')
016 %  disp(['Negative directional distribution. Setting negative values to zero. min(DS) = '  num2str(min(DS(ind)))])
017   DS(ind) = 0;
018 end
019
020 [ix,iy] = find(DS(:,:) ==inf);
021 if any(iy)
022   for iz = iy(:).'
023     ind0 = (DS(:,iz)<inf);
024     DS(ind0,iz)  = 0;
025     DS(~ind0,iz) = 1;
026   end
027 end
028
029 %spy(DS),pause
030
031 %Normalize so that int D(theta,f) dtheta = 1 for each f
032 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033 %Sf2      = simpson(thetai,DS);
034 Sf2 = trapz(thetai,DS);
035
036 %plot(Sf2),pause
037
038 k        = find(Sf2>sqrt(eps) & Sf2<inf);
039 if any(k)
040   DS(:,k)  = DS(:,k)./Sf2(ones(nt,1),k);
041 end
042
043 return```

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