Consecutive Numbers/Logic help

조회 수: 5 (최근 30일)
Edward
Edward 2012년 4월 2일
I have an array of indices: index=[16 17 32 33 48 63 79 80 81 97 98 113 114 129 130]
which each correspond to a value in another array: value=[3 0 2 5 3 2 1 0 0 2 7 7 3 7 8]
the array 'value' has split a few double and triple figure numbers up (from a string) and im trying to reverse that by using the fact that the indexes are consecutive for numbers that should be together. The actual values im trying to get out are: realvalue=[30 25 3 2 100 27 73 78]
so basically removing the space in the array where they shouldnt be... How can i get the array 'realvalue' from the index and value arrays? I hope this makes sense If its any use, ive used regexp(string,'\d') to get numbers from a string obtained from urlread

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 2일
It would be easier to use 'match' with regexp(), and use \d+ to match sequences of digits instead of using \d to match individual digits.
  댓글 수: 3
Edward
Edward 2012년 4월 2일
as ive tried using regexp(string,'\d+','match') and im getting output in the form:
Realval=['30' '25' '3' '2' '100' '27' '73' '78']
which i cant use str2num on and neither can i treat them as integers...
Walter Roberson
Walter Roberson 2012년 4월 2일
Oleg showed the method in your other thread.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by