classdef (Abstract) FileExtractor < handle properties (Abstract, Constant) filename end methods (Static) function output = getVariableFromTextFile(variableName,filename) output = []; assert(ischar(filename),'filename must be a char array') assert(ischar(variableName),'variableName must be a char array') assert( (exist(filename,'file') == 2),'File %s doesn''t exist',filename); fid = fopen(filename,'r'); while and(isempty(output), not(feof(fid))) line = fgetl(fid); variableFound = extractAfter(line,[variableName ' = ']); if not(isempty(variableFound)) eval(['output = ' variableFound ';']); end end assert(not(isempty(output)),'%s has not been found in %s',variableName,filename); fclose(fid); end end end