movevars
Move variables in table or timetable
Syntax
Description
T2 = movevars(
moves the specified variables to the end of the input table. The end is the variable
farthest to the right. (since R2023a)T1
,vars
)
For example, to move a table variable named var3
to the end of
T1
, use T2 = movevars(T1,'var3')
. If the
last variable of T1
is named var5
, then this
syntax moves var3
to the right of var5
.
T2 = movevars(
moves the specified table variables to the right of the table variable indicated by
T1
,vars
,'After',location
)location
. You can specify variables and
location
by name, by position, or by an array of logical
indices. The variable specified by location
can be any variable
in the input table.
For example, to move a table variable named var3
after table
variable var5
, use T2 =
movevars(T1,'var3','After','var5')
.
Before R2023a: If you do not know the name or position of the last variable, you can move
vars
to the end of the table by using the syntaxT2 = movevars(T1,vars,'After',width(T1))
. Thewidth
function returns the number of variables in a table.