MATLAB Answers

Sort complicated Array low -->top

4 views (last 30 days)
Hey Guys I have this Array.Now i need to sort by the Values in the brackets. This Values go from 1 to 255. Does anybody has an idea how i can get this Values ?
InputData
ans =
Columns 1 through 8
'J_012(105)' 'J_013(106)' 'J_014(107)' 'J_015(2)' 'J_016(94)' 'J_017(95)' '

  0 Comments

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 25 Aug 2014
A={'J_012(105)' 'J_013(106)' 'J_014(107)' 'J_015(2)' 'J_016(94)' 'J_017(95)'}
s=regexp(A,'(?<=\().+(?=\))','match')
[~,idx]=sort(str2double([s{:}]))
out=A(idx)

  0 Comments

Sign in to comment.

More Answers (1)

Max Müller
Max Müller on 26 Aug 2014
Matlab says to
[~,idx] = sort(str2double([s{:}]))
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

  1 Comment

Max Müller
Max Müller on 26 Aug 2014
but your idear is greate.... thanks

Sign in to comment.

Sign in to answer this question.

Tags