필터 지우기
필터 지우기

Stack on index digits

조회 수: 1 (최근 30일)
Dimitris M
Dimitris M 2013년 4월 18일
Hello
I have an index vector I need to process and I want to introduce another digit in front of the current index but without summing them.
As an example say I got
Idx=[1 2 3 1 2 3 1 2 3] the value I want to add to this index say is "2"
Is there a way to create the following
IdxNew= [21 22 23 21 22 23 21 22 23]
(the values are not summed - is just the digit 2 is introduced in front of every previous digit)
Is there an easy way to stuck digits like that ?
Thank you in advance

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 4월 18일
idx2 = str2num(regexprep(num2str(Idx),'([0-9]+)','2$1'))
But why do you want to do this? This sounds like there might be a better way around it.
  댓글 수: 1
Dimitris M
Dimitris M 2013년 4월 18일
Yes probably I was just wanted something compact and it occurred to me this as an idea !
Anyway thank you !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by