Creating a new column in a table which is true or false
16 views (last 30 days)
Show older comments
Luca on 6 May 2021
Commented: Luca on 9 May 2021
I have to tables. One is called subsetx the other one is called subsety. In subsetx are two columns one is called ID and the other one SIC. It looks like this:
In subsety i have two rows with value 3990 4920.
I would like to create a new column in subsetx of logical type (true or false)
If variable SIC matches one of the numbers in subsety I would like to get a 1 if not i would like to get a 0.
The proble is you cant compare table with diffrent numbers of row.
I did attached the two subsets.
How can I solve this problem ?
Thank you in advance
Steven Lord on 6 May 2021
id = (1:10).';
SIC = randi(3, 10, 1);
t = table(id, SIC)
t.is1or2 = ismember(t.SIC, [1 2])
More Answers (1)
David Fletcher on 6 May 2021
Edited: David Fletcher on 6 May 2021
Find more on Logical 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!