更改行数据

更改行数据,直接索引到该行并重新赋值即可。

下面创建表T。

code.matlab
>> T=table([1;2;3;4],[5;6;7;8],'VariableNames',{'A' 'B'});
>> T.Properties.RowNames={'a';'b';'c';'d'};

将行名为“d”的行数据乘以2。

code.matlab
>> T('d',:)=T('d',:).*2
T =
  4×2 table
         A    B
         _    __
    a    1     5
    b    2     6
    c    3     7
    d    8    16