remove first element in cell and do not change index of other element
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
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
>>
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays 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!