Azzera filtri
Azzera filtri

convert string into number in table

9 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Star Strider
Star Strider il 7 Mar 2020
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.

Più risposte (0)

Categorie

Scopri di più su Input Specification in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by