How do I convert a text file which has one row of XY co-ordinate data into two separate columns?

3 ビュー (過去 30 日間)
Rogomyster
Rogomyster 2015 年 7 月 15 日
コメント済み: Ingrid 2015 年 7 月 16 日
I am a novice with MATLAB. I have hundreds of text files (named Data1.txt, Data2.txt, Data3.txt etc...) that have XY co-ordinate data of the form:
X0 Y0 X1 Y2 X3 Y3 X4 Y4 ...
There are 400 sets of X-Y co-ordinates per text file. Each data entry is in a separate column (e.g. In Excel for example, X0 would be in cell A1, Y0 is in cell B1 and so on), but all data is in the same row.
Is there a way of converting the data from its current format into two columns, one for X co-ordinate and other for corresponding Y co-ordinates? (By co-ordinates I mean simply numbers only)
i.e
X1 Y1
X2 Y2
X3 Y3
After this I would then like to export the columned data as a new text file (I will be concatenating all text files into one file for ArcMAP implementation. Can this be done in MATLAB?)
Thank you

回答 (1 件)

Ingrid
Ingrid 2015 年 7 月 15 日
read in all the data from the row and then you will have a column vector you could then use
rowData = reshape(A,2,[]);
columnData = rowData';
  2 件のコメント
Rogomyster
Rogomyster 2015 年 7 月 15 日
Thank you very much Ingrid!
Ingrid
Ingrid 2015 年 7 月 16 日
if the solution works for you could you please accept the answer? Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by