How to extract numeric data from a textfile?

조회 수: 3 (최근 30일)
Clayton Ross
Clayton Ross 2017년 9월 25일
댓글: Clayton Ross 2017년 9월 25일
Hi all, is there a method in which I would be able to extract x and y coordinate data from a textfile, when the x and y values are divided by a '/'?
I need to extract and then plot the coordinate data.
The textfile should be attached above. Any help would be greatly appreciated. Thanks :)

채택된 답변

Walter Roberson
Walter Roberson 2017년 9월 25일
편집: Walter Roberson 2017년 9월 25일
S = fileread('P01-GroupM(1).txt');
XYstrs = regexp(S, '^X/Ycoords \(in):\s*(?<X>\S+)\s*/\s*(?<Y>\S+)', 'names', 'lineanchors', 'dotexceptnewline');
X = str2double({XYstrs.X});
Y = str2double({XYstrs.Y});
plot(X, Y)
axis equal

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by