youknownwhat 发表于 2013-6-17 19:59 ![](static/image/common/back.gif)
问题补充,我的数据每行格式:
1,00000,142,1,32400,N,159600,E, ship.obsDay04.rcvJan05
2,0000 ...
still regular expression !!!
假设你的数据存放在cell中- s={'1,00000,142,1,32400,N,159600,E, ship.obsDay04.rcvJan05'
- '2,00000,142,1,32100,N,158500,E, ship.obsDay04.rcvJan05'
- '3,00000,142,1,31400,N,135400,E, ship.obsDay04.rcvJan05'}
复制代码 step: extract digits- d=regexp(s,'\d*','match')
- t=reshape([d{:}],[],numel(d))'
复制代码- t =
- '1' '00000' '142' '1' '32400' '159600' '04' '05'
- '2' '00000' '142' '1' '32100' '158500' '04' '05'
- '3' '00000' '142' '1' '31400' '135400' '04' '05'
复制代码 step2: get Lat or Lon (i guess)- L=regexp(s,'[SNEW]','match')
- Sign=reshape([L{:}],[],numel(L))'
复制代码- Sign =
- 'N' 'E'
- 'N' 'E'
- 'N' 'E'
复制代码 |