matlab - How does rowfun know to reference variables inside a table -
from documentation, see following example:
g = gallery('integerdata',3,[15,1],1); x = gallery('uniformdata',[15,1],9); y = gallery('uniformdata',[15,1],2); = table(g,x,y) func = @(x, y) (x - y); b = rowfun(func,a,... 'groupingvariable','g',... 'outputvariablename','meandiff') when function func applied a in rowfun how know there variables in a called x , y?
edit: feel last statement must not true, not same result if did a = table(g, y, x).
i still confused how rowfun can use function not use variables defined within calling environment.
unless specify rows (and order) name/value argument inputvariables, matlab take column 1 first input, column 2 second input etc, ignoring eventual grouping columns.
consequently, better readability , maintainability of code, consider practice specify inputvariables explicitly.
Comments
Post a Comment