for i = 1:2:length(varargin)
    val = lower(varargin{i});
    switch val
        case 'foo'
            foo = varargin{i+1};
        case 'bar'
            bar = varargin{i+1};
        otherwise
            disp('option not available!');
    end
end