Not able to make dummy variables
Show older comments
Hello.
We have a problem making dummy variables since our variables has ' ' around them ('M'). We have a column with 'M' and 'F' and have to make dummy variables in order to use it in our regression.
How do we fix this?

Answers (1)
C = readcell('data.csv')
dummy_gender = strcmp(C(2:end,4),'''M''')
2 Comments
Malene Brautaset
on 25 Mar 2022
You're welcome!
Sure, here is a table version:
T = readtable('data.csv')
dummy_gender = strcmp(T{:,'gender'},'''M''')
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!