Issue while converting java.lang.string to number
古いコメントを表示
Hello everyone!
I have a code that reads part of a xml file using getTextContent method. The output data is a java.lang.String type string. This is usually a N×3 looking string on which I do str2num() to make a N×3 matrix. So far it worked without any issue. But I came to a problem while my data format was like this:
val =
-4.5600 ********** 201.2678
-4.5594 37.8202 201.2920
-4.5587 37.8767 201.3163
-4.5581 37.9339 201.3406
-4.5574 37.9918 201.3649
-4.5568 38.0504 201.3892
-4.5562 38.1098 201.4136
-4.5555 38.1698 201.4380
-4.5549 38.2305 201.4625
Now asterisk (*) being a special character in Matlab, while I do str2num() on the string it returns an empty matrix. The first line is not so important, so I tried to get rid of the first line. As it is a java string, I failed to do it. I tried converting it to char by doing char(val) but it becomes 1×(N*3) char which makes it hard to process.
I would like to get rid of the first line & have the java string converted to a (N-1)×3 matrix. Any clue? The string I am trying to convert is uploaded as a mat file here.
I understand xml2struct can convert XML data directly to numbers, but my whole code is written using xmlread() so I cannot go back and rewrite everything due to this problem.
Any help is really appreciated.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!