how to use the split function the below dataset
Afficher commentaires plus anciens
raw={'12_peeter','14_kumar','34_jai','56_papu'}
how to replace this format
a={'peeter-12','kumar-14','jai-34','papu-56'}
but iam try split function
temp=raw;
for i=1:length(temp)
a=strsplict(temp(i),'_');
temp=strcat(temp1(2),'-',temp1(1));
raw(i)=temp;
end
but it gives
??? Undefined function or method 'strsplict' for input arguments of type 'char'.
Réponse acceptée
Plus de réponses (2)
Walter Roberson
le 4 Jan 2017
0 votes
You misspelled strsplit()
Stephen23
le 4 Jan 2017
>> raw = {'12_peeter','14_kumar','34_jai','56_papu'};
>> out = regexprep(raw,'(\d+)_(\w+)','$2-$1');
And checking the output:
>> out{:}
ans = peeter-12
ans = kumar-14
ans = jai-34
ans = papu-56
Catégories
En savoir plus sur NaNs dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!