how to Enter same string in whole column?

22 visualizaciones (últimos 30 días)
Akashdeep Kaur
Akashdeep Kaur el 16 de Jul. de 2022
Comentada: Akashdeep Kaur el 18 de Jul. de 2022
Hello, I have a Table some of its columns have variable value but for some i have to fix the column value with a string.
for example:
col1
"str1"
"str1"
"str1"
"str1"
Thank you.

Respuesta aceptada

Voss
Voss el 16 de Jul. de 2022
% a table with varying values:
t = table( ...
["str1";"str2";"str3";"str4";"str5"], ...
[1;2;3;4;5], ...
'VariableNames',{'col1','col2'})
t = 5×2 table
col1 col2 ______ ____ "str1" 1 "str2" 2 "str3" 3 "str4" 4 "str5" 5
% set all the values in col1 to "str1":
t.col1(:) = "str1"
t = 5×2 table
col1 col2 ______ ____ "str1" 1 "str1" 2 "str1" 3 "str1" 4 "str1" 5

Más respuestas (1)

Jan
Jan el 16 de Jul. de 2022
T = table('Size', [5, 2], 'VariableTypes', {'string', 'double'});
T{:, 1} = "str"
T = 5×2 table
Var1 Var2 _____ ____ "str" 0 "str" 0 "str" 0 "str" 0 "str" 0

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by