
%READLIST
% list = readlist(filename)

% read a list of string values line by line from a text file. 
% Ignores any line starting with the '%' character

function [list, success] = readlist(filename)

list = {}; %list is a cell array

success = 1;
% open the text file
fid=fopen(filename); 

% if file opened successfully
if fid ~= -1
    
    while 1 
        line = fgetl(fid);
        
        %break on end of file
        if ~ischar(line), break, end

        %if the line starts with a % then ignore it
        if length(line) && line(1) ~= '%' 
            % otherwise put current line into output list
            list = [list line];
        end  

    end
    
    % close the file
    fclose(fid);
else
    success = 0;
end

