Extracting numeric values from character array
이전 댓글 표시
Hi, I have a character array "coords" (containing 3D coordinates), which looks something like this:
val =
'[ 48. -24. 48.]'
'[ 50. -22. 58.]'
'[ 48. -20. 50.]'
I would like to find the index of a specific coordinate, something like:
find(coords == [50 -22 58])
How do I do that? Transforming coords as follows:
coords_num = str2double(coordinates)
just leads to:
coords_num = NaN
댓글 수: 1
Paolo
2018년 9월 16일
What is the output of
>> coords
?
채택된 답변
추가 답변 (1개)
Walter Roberson
2018년 9월 16일
T = regexp( regexprep(coordinates, '\[|\]', ''), 'split') ;
coords_num = str2double(T) ;
댓글 수: 3
MiauMiau
2018년 9월 16일
Walter Roberson
2018년 9월 16일
Use cellstr(coordinates) where I had coordinates()
MiauMiau
2018년 9월 17일
카테고리
도움말 센터 및 File Exchange에서 String에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!