Changing Data in a Table

2 visualizaciones (últimos 30 días)
Annika Pedersen
Annika Pedersen el 10 de Mayo de 2021
Respondida: KSSV el 10 de Mayo de 2021
I have a table that exhibits a sex column with Male as 'M' and female as 'F'. How do I change these M & F's to Male and Female? Any help would be greatly appreciated.

Respuestas (1)

KSSV
KSSV el 10 de Mayo de 2021
Name = {'Al Pacino', 'Angelina Jolie','Robert De Niro','Russel Crowe','Kate Winslet','Julia Roberts'} ;
Sex = {'M','F','M','M','F','F'} ;
T = table(Name',Sex','VariableNames',{'Name','Sex'}) ;
T
% Change data
T.Sex(strcmp(T.Sex,'M')) = {'Male'} ;
T.Sex(strcmp(T.Sex,'F')) = {'Female'} ;
T

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by