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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -