How can I parse the string to extract numbers into two matrices

Hello,
I have the following string that I need to parse in order to extract the numbers into two different arrays. The string is as follows:
T01D002T02D004T03D006T04D008T05D010T06D012T07D014T08D016T09D018T10D020T11D022T12D024T13D026T14D028T15D030T16D032T17D034T18D036T19D038T20D040T21D042T22D044T23D046T24D048T25D050T26D052T27D054T28D056T29D058T30D060
The T and D are the placeholders to indicate Time and Data value. I need to create two arrays as follows: Time=1 2 3 etc. Data=2 4 6 etc.
Any timely help is much appreciated.

 Réponse acceptée

This one is trivial...assume s is the string, then
>> cell2mat(textscan(s,'T%2dD%3d','collectoutput',1))
ans =
1 2
2 4
3 6
...elided for brevity...
28 56
29 58
30 60
>>

1 commentaire

Thank you very much for your timely help. It worked as expected. Regards, Ravi

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Question posée :

le 29 Jan 2016

Commenté :

le 29 Jan 2016

Community Treasure Hunt

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

Start Hunting!

Translated by