function [points] = readPol(fname) %% reads a Delft3D polygon into a cell array opts = delimitedTextImportOptions("NumVariables", 5); % Specify range and delimiter opts.DataLines = [9, Inf]; opts.Delimiter = " "; % Specify column names and types opts.VariableNames = ["VarName1", "Coordinate", "Var3", "Var4", "Var5"]; opts.SelectedVariableNames = ["VarName1", "Coordinate"]; opts.VariableTypes = ["double", "double", "string", "string", "string"]; % Specify file level properties opts.ExtraColumnsRule = "ignore"; opts.EmptyLineRule = "read"; opts.ConsecutiveDelimitersRule = "join"; opts.LeadingDelimitersRule = "ignore"; % Specify variable properties opts = setvaropts(opts, ["Var3", "Var4", "Var5"], "WhitespaceRule", "preserve"); opts = setvaropts(opts, ["Var3", "Var4", "Var5"], "EmptyFieldRule", "auto"); % Import the data NCShoreALL = readtable(fname, opts); %% Convert to output type NCShoreALL = table2array(NCShoreALL); %% Clear temporary variables clear opts SegCount = 1; PtsCount = 1; for Line = 2:length(NCShoreALL) if isnan(NCShoreALL(Line,1))==1 elseif Line>3 && isnan(NCShoreALL(Line-1,1))==1 continue elseif Line>3 && isnan(NCShoreALL(Line-2,1))==1 PtsCount = 1; SegCount = SegCount+1; continue else points{SegCount}(PtsCount,:) = NCShoreALL(Line,:); PtsCount = PtsCount+1; end end end