How to load a .gpx file with an invalid field name

7 ビュー (過去 30 日間)
Meg Carr
Meg Carr 2021 年 5 月 12 日
回答済み: Pratyush 2024 年 5 月 27 日
Hello,
I am attempting to load a gpx file that should contain the tracklines of a ship.
m1= gpxread('tracks.gpx');
Some of the data loads into the workspace, but eventually the following error occurs, and all data is lost.
Error using tracklines (line 20)
Invalid field name: ''.
Unrecognized function or variable 's11'.
I am unable to change the field names outside of MatLab. How should I proceed?
Thank you.

回答 (1 件)

Pratyush
Pratyush 2024 年 5 月 27 日
Hi Meg,
To address the issue of loading a GPX file in MATLAB when encountering errors due to invalid field names, follow these steps:
  • Open and read the contents of the GPX file into MATLAB as a string, instead of directly using `gpxread`. This allows you to inspect and potentially modify the file's content.
  • Use string operations to find and correct or remove invalid field names within the GPX file content. For example, replace empty or problematic tags with acceptable placeholders.
  • If modifications were made, save the corrected content to a new GPX file. This preserves the original file and gives you a potentially loadable version of the data.
  • Attempt to load the modified GPX file using MATLAB's `gpxread` function, which should now work if the modifications addressed the issue.
This approach allows you to work around the problem without needing to alter the GPX file outside of MATLAB, accommodating situations where direct file editing isn't feasible or preferred.

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by