function [WL fieldname]=readTides(varargin) OPT = struct(... 'tidespath', 'D:\pruis\Checkouts\tudelft\Chandeleurs_Islands\InputData\Buoy\Tides',... 'location',4,... 'visualize',0); fullfile(fileparts(which(mfilename))),'..','InputData','Buoy','Tides') OPT = setproperty(OPT, varargin{:}); matfiles = dir(fullfile(OPT.tidespath, '*.mat')); for ifile = 1:length(matfiles) fnames{ifile} = matfiles(ifile).name; end station_names = strrep(fnames, '.mat', ''); %% for i = 1:length(fnames) temp = load(fnames{i}); fieldname{i,1} = station_names(i); WL.(fieldname{i,1}{1,1}).time = temp.tide(:,1); WL.(fieldname{i,1}{1,1}).predictions= temp.tide(:,2); WL.(fieldname{i,1}{1,1}).measurements= temp.tide(:,3); end if OPT.visualize==1 for i = OPT.location figure('Name',(fieldname{i,1}{1,1})); % plot(WL.(fieldname{i,1}{1,1}).time,WL.(fieldname{i,1}{1,1}).predictions);hold on; plot(WL.(fieldname{i,1}{1,1}).time,WL.(fieldname{i,1}{1,1}).measurements, 'r'); title((fieldname{i,1}{1,1})); datetick('x'); end end