I have a table called NYLD1 and I want to create some new variables that are the squares and cubes of the variables columns 29:32 so I wrote the following:
cur_varnames = NYLD1.Properties.VariableNames;for K = [29:32] thisvarname = cur_varnames{K}; thisval = NYLD1.(thisvarname); sq_varname = [thisvarname '2']; cu_varname = [thisvarname '3']; NYLD1.(sq_varname) = thisval .^ 2; NYLD1.(cu_varname) = thisval .^ 3;end
However, I get the following error when I run this:
Undefined function 'power' for input arguments of type 'table'.
How can I fix this?
Best Answer