MATLAB: Convert string into number in table

ismember replace str2doubleMATLAB

Hi
attached file is a table with
'STANDING','SITTING','LAYING','WALKING','WALKING_DOWNSTAIRS','WALKING_UPSTAIRS'
could you please help how to convert them into numers
i tired
targetSet1 = table2array(TargetSet)
z = cellfun(@(x){x(1),x(2),x(3:end)},targetSet1,'un',0);
TargetSet = str2double([z{:}]);
but its converting all into Nan plus output is in columns not rows
i need output as single column in double format where the values are numeric only
Thank you in advance

Best Answer

I am not certain what you intend by ‘numbers’, so guessing:
D = load('TargetSet.mat');
TargetSet = D.TargetSet;
ActivityCode = table(findgroups(TargetSet.Activity), 'VariableNames',{'ActivityCode'});
TargetSet = [TargetSet, ActivityCode];
First15Rows = TargetSet(1:15,:)
producing:
First15Rows =
Activity ActivityCode
___________ ____________
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'SITTING'} 2
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
{'LAYING' } 1
If you want a different result, please describe it in some detail.