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

조회 수: 3 (최근 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 CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by