Borrar filtros
Borrar filtros

How can I add a column with labelining in a matrix

2 visualizaciones (últimos 30 días)
Sazid Hasan
Sazid Hasan el 27 de Ag. de 2021
Comentada: Sazid Hasan el 27 de Ag. de 2021
I have data matrix. I have to add label column with same name Before in the matrix. How I can add this labeling?

Respuesta aceptada

Chunru
Chunru el 27 de Ag. de 2021
% 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 comentario
Sazid Hasan
Sazid Hasan el 27 de Ag. de 2021
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.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by