Skip to content

Instantly share code, notes, and snippets.

@ferryzhou
Created May 3, 2012 14:37
Show Gist options
  • Save ferryzhou/2586075 to your computer and use it in GitHub Desktop.
Save ferryzhou/2586075 to your computer and use it in GitHub Desktop.
Initialize variable based on options from input
function val = init_option(options, name, default_val)
% usage lamda = init_option(options, 'lamda', 0.01);
if isfield(options, name), val = options.(name); else val = default_val; end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment