How to add a new column in table?

1 view (last 30 days)
I have a csv file with 32 columns. I have used readtable to read the csv file. The second column is gender(M or F) values. I want to include a extra column (33rd column) which will store -1 for female and +1 for male (integer vlaues).

Accepted Answer

Walter Roberson
Walter Roberson on 14 Oct 2019
YourTablename.GenderCode = strcmp(YourTablename.gender, 'M')*2 - 1; %+1 for M, -1 otherwise

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!