how to use the split function the below dataset
显示 更早的评论
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'.
采纳的回答
更多回答(2 个)
Stephen23
2017-1-4
>> 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
类别
在 帮助中心 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!