How can I add a column with labelining in a matrix

2 次查看(过去 30 天)
I have data matrix. I have to add label column with same name Before in the matrix. How I can add this labeling?

采纳的回答

Chunru
Chunru 2021-8-27
% Create a table with some data
a = (1:10)'; b=rand(10, 1); c=randi([1,100], 10, 1);
T = table(a, b, c)
T = 10×3 table
a b c __ _______ __ 1 0.31924 57 2 0.41572 9 3 0.33329 31 4 0.52433 42 5 0.60832 6 6 0.56471 1 7 0.19825 51 8 0.20861 67 9 0.75822 19 10 0.8956 96
% Now add the label
T.label = repmat("Before", 10, 1);
T = T(:, [end 1:end-1])
T = 10×4 table
label a b c ________ __ _______ __ "Before" 1 0.31924 57 "Before" 2 0.41572 9 "Before" 3 0.33329 31 "Before" 4 0.52433 42 "Before" 5 0.60832 6 "Before" 6 0.56471 1 "Before" 7 0.19825 51 "Before" 8 0.20861 67 "Before" 9 0.75822 19 "Before" 10 0.8956 96
  1 个评论
Sazid Hasan
Sazid Hasan 2021-8-27
Thank you very much. If I split label like before and after 5 for before and 5 for after how it will be done? As i try define the size, it not working.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by