remove first element in cell and do not change index of other element

4 ビュー (過去 30 日間)
NA
NA 2019 年 8 月 10 日
回答済み: dpb 2019 年 8 月 10 日
I have A, and want to remove first index from remain index
A={[1,2,3],[2,6,8,7],[4,5,6,7,8,9,10]};
first_index=cellfun(@(v) find(v(1)),A,'uni',0);
remain_index=cellfun(@(v) ~ismember(v(1),v),A,'uni',0); % I have problem in this part
result should be
first_index={[1],[1],[1]};
remain_index={[2,3],[2,3,4],[2,3,4,5,6,7]} % remove first index

採用された回答

dpb
dpb 2019 年 8 月 10 日
You're overthinking the problem...the first index is always 1...
>> cellfun(@(a) 2:numel(a),A,'uni',0)
ans =
1×3 cell array
{1×2 double} {1×3 double} {1×6 double}
>> ans{:}
ans =
2 3
ans =
2 3 4
ans =
2 3 4 5 6 7
>>

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by