%This script is designed to separate the nortek processed wave directional %spectra into seperate date files %first load the spectral file as spec and the wave detail file as details %also load the directional energy file as dirspec and the frequency %spectrum file as freqspec month=details(:,1); day=details(:,2); year=details(:,3); hour=details(:,4); minute=details(:,5); second=details(:,6); %next set up the data and time in the right format time=datenum(year,month,day,hour,minute,second); datelist=datestr(time, 'yymmddHHMM'); %now go through each spectrum, cut out each one from the file and create a %new text file with the datestamp. for i=2:length(datelist) startpos=(i*40)-39; %(where 40 is the number of frequencies used per spectra) stoppos=(i*40); specfile=spec(startpos:stoppos,:); freqs=freqspec(i,:); %need to change from normalized values so have to multiply through by the freq power spectrum mult=freqs'*ones(1,90); specfilemult=(mult.*specfile)/4; %this is the 3d spectrum in m^2s/deg dateinfo=datelist(i-1,:); name=strcat('nortekspec_',dateinfo,'.txt'); dlmwrite(name, specfilemult, ' '); end %now do the same thing for the dirspec file and the freqspec file for i=2:length(datelist) dirspecfile=dirspec(i,:); freqspecfile=freqspec(i,:); dateinfo=datelist(i,:); namedir=strcat('nortekdirspec_',dateinfo,'.txt'); namefreq=strcat('nortekfreqspec_',dateinfo,'.txt'); dlmwrite(namedir, dirspecfile, ' '); dlmwrite(namefreq, freqspecfile, ' '); end