How can I withdraw a colon operator from a string
1 回表示 (過去 30 日間)
古いコメントを表示
I have a colon operator within a string input (<1x30> char) that I would like to withdraw for later plotting.
The variable input is this:
WIND = NORTHEAST WINDS 8 : 13 KNOTS
I want just the characters
'8 : 13'
and make them operate as a colon operator. I was thinking of using a variation of 'find' command, but I don't know how to tell MATLAB to find colon operators within a text string.
Can you please help?
0 件のコメント
回答 (3 件)
Azzi Abdelmalek
2012 年 8 月 17 日
編集済み: Azzi Abdelmalek
2012 年 8 月 17 日
c1='WIND = NORTHEAST WINDS 8 : 13 KNOTS'
a=regexp(c1,'[0-9]')
result=c1(min(a):max(a))
0 件のコメント
Matt Kindig
2012 年 8 月 17 日
編集済み: Matt Kindig
2012 年 8 月 17 日
Mr. Azzi's technique is more general, and I would use it for your purpose.
However, if you did want to use 'find' to locate specific characters in a text string, you can do it simply as:
a = 'WIND = NORTHEAST WINDS 8 : 13 KNOTS'
location = find(a==':');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!