function [Bias, I, dIdV] = ImportVERTFileV3(filename, dataLines) %IMPORTFILE Import data from a VERT file % [VARNAME1, VARNAME2, VARNAME3, VARNAME4, VARNAME5, VARNAME6] = % IMPORTFILE(FILENAME) reads data from text file FILENAME for the % default selection. Returns the data as column vectors. % % [VARNAME1, VARNAME2, VARNAME3, VARNAME4, VARNAME5, VARNAME6] = % 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, VarName2, VarName3, VarName4, VarName5, VarName6] = importfile("C:\LocalUserData\User-data\aaprom1\Matlab\Import functions\Createc2200306.153317.L0008.VERT", [617, Inf]); % % See also READTABLE. % % Auto-generated by MATLAB on 20-Oct-2020 13:23:36 % Modified by Markus Aapro, Feb 2021 %% Input handling % If dataLines is not specified, define defaults if nargin < 2 dataLines = [596, Inf]; end %% Setup the Import Options and import the data opts = delimitedTextImportOptions("NumVariables", 6); % Specify range and delimiter opts.DataLines = dataLines; opts.Delimiter = ["\t", " ", "="]; % Specify column names and types opts.VariableNames = ["VarName1", "VarName2", "VarName3", "VarName4", "VarName5", "VarName6"]; opts.VariableTypes = ["double", "double", "double", "double", "double", "double"]; % Specify file level properties opts.ExtraColumnsRule = "ignore"; opts.EmptyLineRule = "read"; % Specify variable properties opts = setvaropts(opts, ["VarName1", "VarName2", "VarName3"], "TrimNonNumeric", true); opts = setvaropts(opts, ["VarName1", "VarName2", "VarName3"], "ThousandsSeparator", ","); % Import the data tbl = readtable(filename, opts); %% Convert to output type % Bias channel: [mV] Bias = tbl.VarName2; % Current: [A] I = tbl.VarName4.*1e-3*1e-10; % Multipliers come from preamplifier gain and millivolt conversion % dIdV: [arbitrary units] dIdV = tbl.VarName5; end