sampsapursiainen / zeffiro_interface

Interface for using finite elements in inverse problems with complex domains
GNU General Public License v3.0
24 stars 15 forks source link

Simplify main function zeffiro_interface argument parsing #141

Closed SeSodesa closed 1 year ago

SeSodesa commented 1 year ago

Currently the zeffiro_interface main function's way of handling key–value arguments does not follow Matlab's best practices, which involves using an arguments ... end block to declare key–value argument pairs as follows:

function output = f(args)

    arguments
        args.arg1 (sizes...) type {validators...} = default_value;
        args.arg2 (sizes...) type {validators...} = default_value;
        ...
        args.argn (sizes...) type {validators...} = default_value;
    end

    output = function_of(args);

end

This allows calling the function f with

output = f("arg1", value1, "arg2", value2, ..., "argn", valuen);

or from Matlab r2021a onwards with

output = f(arg1=value1, arg2=value2, ..., argn=valuen);

No need to use a loop or increment a counter / index with this method.

SeSodesa commented 1 year ago

Closed by #152.