How to add a new column in table?

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

YourTablename.GenderCode = strcmp(YourTablename.gender, 'M')*2 - 1; %+1 for M, -1 otherwise

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!