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

2 vues (au cours des 30 derniers jours)
NA
NA le 10 Août 2019
Réponse apportée : dpb le 10 Août 2019
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

Réponse acceptée

dpb
dpb le 10 Août 2019
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
>>

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by