我想生成一个表,但想设置变量名只有一个变量,但希望所有其他变量保持他们的名字。如何在MATLAB表中只重新命名几个变量?
例, 说我有这样的数据:
User1 = rand(5,1);
User2 = rand(5,1);
User3 = rand(5,2);
我现在可以使用使表:
table(User1 , User2 , User3(:,1))
这给了我这样的:
ans =
User1 User2 Var3
________ ________ ________
0.55229 0.049533 0.14651
0.62988 0.48957 0.18907
0.031991 0.19251 0.042652
0.61471 0.12308 0.6352
0.36241 0.20549 0.28187
我想得到这样的:
ans =
User1 User2 User3
________ ________ ________
0.55229 0.049533 0.14651
0.62988 0.48957 0.18907
0.031991 0.19251 0.042652
0.61471 0.12308 0.6352
0.36241 0.20549 0.28187
我试着这样做:
table(User1 , User2 , User3(:,1), 'VariableNames',{'','','User3'})
但是这给了错误:
Error using setVarNames (line 33)
The VariableNames property must be a cell array, with each element containing one nonempty
string.
Error in table (line 305)
t = setVarNames(t,vnames); % error if invalid, duplicate, or empty
如何解决我的问题与MATLAB 2014B?
对于我的数据,d
被生成,并且表被制成一个循环,我想保留d
的所有值。如果这事很重要。
参见:改变一个变量名称](https://www.mathworks.com/help/matlab/matlab_prog/modify-units-descriptions-and-table-variable-names.html#zmw57dd0e25360 )或[访问和修改属性](https://www.mathworks.com/help/matlab/ref/tableproperties.html) – excaza