我有一个名为15x7
的{{1}}双打矩阵。我想要做的是添加一个额外的行和列作为行和列的标题名称,这些行和列将保存为矩阵A
,其大小为B
。
16x8
我已尝试将新列保存在向量A=
1 1 -27.84543037 235.8829193 1529.838379 309.5192566 151.2160492
1 1 -25.76914215 22.570755 1521.290161 310.2462463 231.4568634
1 1 -162.0449066 19.34294128 1515.019287 258.4113464 232.6483002
1 1 -316.8930359 -106.8941193 1407.015625 190.3127441 283.7460022
1 1 -300.2756958 139.7964783 1365.73584 193.3990479 181.0596008
1 1 110.5066299 25.79856873 1527.561035 361.6555786 230.2752075
1 1 296.7176208 -125.0899811 1428.061768 439.6409607 290.4381409
1 1 281.2500305 118.227478 1377.988037 437.5250854 190.5966339
1 1 -21.2894783 -170.6610107 1523.40271 311.9530029 304.5064392
1 1 -105.9274673 -366.0036011 1521.414429 279.9092102 378.5228271
1 1 -178.0385742 -654.3458252 1275.617554 239.6331177 535.3726807
1 1 -247.3761902 -931.5979614 1039.274658 182.9398804 756.1568604
1 1 72.30783844 -361.7819214 1529.616089 347.2199097 376.1908569
1 0.5 137.2854919 -687.1557617 1330.945068 379.3947449 537.2888184
1 0.5 206.1542358 -984.8857422 1119.07019 426.0763245 746.7713623
B=
AA BB CC DD EE FF GG
EE 1 1 -27.84543037 235.8829193 1529.838379 309.5192566 151.2160492
FF 1 1 -25.76914215 22.570755 1521.290161 310.2462463 231.4568634
GG 1 1 -162.0449066 19.34294128 1515.019287 258.4113464 232.6483002
HH 1 1 -316.8930359 -106.8941193 1407.015625 190.3127441 283.7460022
II 1 1 -300.2756958 139.7964783 1365.73584 193.3990479 181.0596008
JJ 1 1 110.5066299 25.79856873 1527.561035 361.6555786 230.2752075
KK 1 1 296.7176208 -125.0899811 1428.061768 439.6409607 290.4381409
LL 1 1 281.2500305 118.227478 1377.988037 437.5250854 190.5966339
MM 1 1 -21.2894783 -170.6610107 1523.40271 311.9530029 304.5064392
NN 1 1 -105.9274673 -366.0036011 1521.414429 279.9092102 378.5228271
OO 1 1 -178.0385742 -654.3458252 1275.617554 239.6331177 535.3726807
PP 1 1 -247.3761902 -931.5979614 1039.274658 182.9398804 756.1568604
QQ 1 1 72.30783844 -361.7819214 1529.616089 347.2199097 376.1908569
RR 1 0.5 137.2854919 -687.1557617 1330.945068 379.3947449 537.2888184
SS 1 0.5 206.1542358 -984.8857422 1119.07019 426.0763245 746.7713623
中,然后将其添加到newcol=['AA','BB','CC,'DD','EE','FF','GG']
,如A
,然后对行执行相同操作。但它不起作用,所以如果有人可以请告诉我该怎么做。
答案 0 :(得分:3)
B = table( A(:,1),A(:,2),A(:,3),A(:,4),A(:,5),A(:,6),A(:,7),...
'VariableNames', {'AA'; 'BB'; 'CC'; 'DD'; 'EE'; 'FF'; 'GG'},...
'RowNames', {'EE','FF','GG','HH','II','JJ','KK','LL','MM','NN','OO','PP','QQ','RR','SS'});
% they will yield the same values
B{2,3}
B{'FF', 'CC'}
注意:它仅适用于MATLAB R2014A