How to add a new column in table?
1 view (last 30 days)
Show older comments
Rohit Kumar
on 14 Oct 2019
Answered: Walter Roberson
on 14 Oct 2019
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).
0 Comments
Accepted Answer
Walter Roberson
on 14 Oct 2019
YourTablename.GenderCode = strcmp(YourTablename.gender, 'M')*2 - 1; %+1 for M, -1 otherwise
0 Comments
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!