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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!