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)' '

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 25 日

0 投票

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)

その他の回答 (1 件)

Max Müller
Max Müller 2014 年 8 月 26 日

0 投票

Matlab says to
[~,idx] = sort(str2double([s{:}]))
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

1 件のコメント

Max Müller
Max Müller 2014 年 8 月 26 日
but your idear is greate.... thanks

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Shifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by