function refurb = importproto(filename, dataLines) %IMPORTFILE Import data from a text file % REFURB = IMPORTFILE(FILENAME) reads data from text file FILENAME for % the default selection. Returns the data as a table. % % REFURB = IMPORTFILE(FILE, DATALINES) reads data for the specified row % interval(s) of text file FILENAME. Specify DATALINES as a positive % scalar integer or a N-by-2 array of positive scalar integers for % dis-contiguous row intervals. % % Example: % refurb = importfile("/home/lebars/Documents/Doctorate/codes/espic2d/matlab/Magnetic_Field_GLS_2020/refurb.data", [5, Inf]); % % See also READTABLE. % % Auto-generated by MATLAB on 24-Mar-2022 17:18:34 %% Input handling % If dataLines is not specified, define defaults if nargin < 2 dataLines = [2, Inf]; end %% Setup the Import Options and import the data opts = delimitedTextImportOptions("NumVariables", 3); % Specify range and delimiter opts.DataLines = dataLines; opts.Delimiter = " "; % Specify column names and types opts.VariableNames = ["Z", "R", "phi"]; opts.VariableTypes = ["double", "double", "double"]; % Specify file level properties opts.ExtraColumnsRule = "ignore"; opts.EmptyLineRule = "read"; % Specify variable properties %opts = setvaropts(opts, "Z", "TrimNonNumeric", true); opts = setvaropts(opts, "Z", "ThousandsSeparator", ","); % Import the data refurb = readtable(filename, opts); end