MATLAB: Add a variable to a table MATLABtable Suppose I have a table T. I want to add a variable x to T. Please advise the steps. Best Answer If your table is named T, and your workspace variable is named k, and you want the new variable in the table to be named k, then it's justT.k = k Related SolutionsMATLAB: How to add variables to a table that are products of other variables cur_varnames = YourTable.Properties.VariableNames;for K = [10, 12:18] thisvarname = cur_varnames{K}; thisval = YourTable.(thisvarname); sq_varname = [thisvarname '_squared']; cu_varname = [thisvarname '_cubed']; YourTable.(sq_varname) = thisval .^ 2; YourTable.(cu_varname) = thisval .^ 3;end MATLAB: Adding a variable to a table Hi,From my understanding you are trying make your first row as the variables of your table Tx. The following script would help you achieve it.load TxVarNames = string(cell2mat(table2cell(Tx(1,:))));Tx(1,:) = [];Tx.Properties.VariableNames = VarNames; Related QuestionDoes table creation produce error “VariableNames property must contain one name for each variable in the table”Joining 2 tables to make 1 tableAdding a column to tableCreate a new table based on variables of other tables (WITH DIFFERENT LENGTHS)
Best Answer