function w = readgauges(fn) % Reads files in .txt format recorded with Njord Runtime. % Choosing to record one paddle data and several wavegauges are possible % % Input: % fn: File name; txt format % % This works if you have chosen 1 paddle motion and maximum 2 gauges in the % wave maker software. % Output: % w: structure % Data to analyse % w.time = [sec] timevec from first 3 data columns % w.rad = [rad] data from one paddle, column 4 % w.data = [meter] data from all gauges, but can also include paddle % position and other data chosen to be saved in Njord software, % check file, columns marked with "Gauge" are wavedata! % replace strange digital data last column 'x' character with point '.' fid = fopen(fn); f=fread(fid,'*char')'; fclose(fid); f = strrep(f,'x','.'); fid = fopen(fn,'w'); fprintf(fid,'%s',f); fclose(fid); ifp = fopen(fn); if ifp<0 disp(['Could not open file ' fn]) [y,fs] = audioread('mcsound.wav') sound(y,fs); return; end w.filename = fn; s=fgetl(ifp); w.fileinfo = s; s=fgetl(ifp); w.header1 = s; s=fgetl(ifp); w.header2 = strsplit(s); s=fgetl(ifp); w.header3 = strsplit(s); s=fgetl(ifp); w.headerunit = strsplit(s); w.cols=length(w.headerunit); tmp=textscan(ifp,'%f','delimiter',':'); tmp2=tmp{1}; w.frames_check=length(tmp2)/(w.cols+2); w.data_raw1 = reshape(tmp2',w.cols+2,w.frames_check)'; w.hr=w.data_raw1(:,1); w.min=w.data_raw1(:,2); w.sec=w.data_raw1(:,3); timetmp= w.hr * 3600 + w.min * 60 + w.sec; w.timetmp=timetmp-timetmp(1); w.time=(0:w.timetmp(end)/(length(w.timetmp)-1):w.timetmp(end))'; % make timestep exact, you can check, there is no big difference w.data=w.data_raw1(:,4:w.cols+2); w.freq=round(1/(w.time(2)-w.time(1))); % should be 128ish from edesign software w.frames=length(w.timetmp); w.data_raw=[w.time w.data]; w.frames_raw=w.frames; w.freq_raw=w.freq; fclose(ifp);