Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How to change data into something else?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a set of data {1-001,1-002,1-003....1-054} how do I take the data and produce something like this {1-N1,1-T1,1-N2,1-T2,1-N3,1-T3....1-N54,1-T54}.
4 件のコメント
回答 (1 件)
Star Strider
2014 年 2 月 28 日
There may be move elegant and efficient solutions, but this works. You can experiment with the Data2 statement to get the sort of output you want. I organised it as columns for convenience in troubleshooting the code.
Data = {'1-001','1-002','1-003','1-054','2-054','3-054'}
for k1 = 1:size(Data,2)
str = Data{k1};
strptx = strsplit(str, '-');
strvct = str2double(strptx);
Data2{k1,:} = sprintf('%d-N%d, %d-T%d\n',strvct,strvct);
end
char(Data2)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!