Parsing one line data-set into array using textscan?

Hi!
I am trying to parse the return from a traceroute system command. The output from it comes from a single row, single column char of around 600 characters:
Data example:
1 192.168.0.1 1.610 ms 1.211 ms 1.459 ms 2 146.172.110.121 25.653 ms 30.442 ms 29.061 ms 3 146.172.99.125 39.904 ms 51.665 ms 38.419 ms
Now, I have had no problems with parsing the first part of this into an array, but I would like to make a new row in the array for each new index, e.g. 1, 2, 3 as can be seen in the data above.
The end result would be something like (but in an array/matrix):
1 192.168.0.1 1.610 ms 1.211 ms 1.459 ms
2 146.172.110.121 25.653 ms 30.442 ms 29.061 ms
3 146.172.99.125 39.904 ms 51.665 ms 38.419 ms
Current Code:
[status, result] = system('traceroute -n 209.85.173.147 2> /dev/null | head -30 ');
TraceArray = textscan(result,'%f %s %f %*s %f %*s %f', 'delimiter', ' ', 'MultipleDelimsAsOne', 1);
with Best Regards,
Adam

 採用された回答

TAB
TAB 2012 年 1 月 5 日

0 投票

TraceArray = textscan(result,...
'%f %s %f %*s %f %*s %f %s', 'delimiter', ' ', 'MultipleDelimsAsOne', 1)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by