Contents
function VarName1 = importfile(filename, dataLines)
%IMPORTFILE Import data from a text file % VARNAME1 = IMPORTFILE(FILENAME) reads data from text file FILENAME % for the default selection. Returns the data as column vectors. % % VARNAME1 = 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: % VarName1 = importfile("C:\Users\tjagielski\Documents\Projects\School\Sophomore - Semester 1\QEA 2\Module 2\EEG Data\F.txt", [1, Inf]); % % See also READTABLE. % % Auto-generated by MATLAB on 28-Nov-2019 17:38:14
Input handling
% If dataLines is not specified, define defaults if nargin < 2 dataLines = [1, Inf]; end
Setup the Import Options
opts = delimitedTextImportOptions("NumVariables", 1); % Specify range and delimiter opts.DataLines = dataLines; opts.Delimiter = ","; % Specify column names and types opts.VariableNames = "VarName1"; opts.VariableTypes = "double"; opts.ExtraColumnsRule = "ignore"; opts.EmptyLineRule = "read"; % Import the data tbl = readtable(filename, opts);
Convert to output type
VarName1 = tbl.VarName1;
end