필터 지우기
필터 지우기

compare a vector with every cells element and get the missing

조회 수: 2 (최근 30일)
Hamid Salari
Hamid Salari 2017년 8월 7일
댓글: Star Strider 2017년 8월 7일
hi . i have a vector V=[1:100] and a C=cell(1-n) with double[] values . how could i get the values in the vector that are not in any element of cell ? and another question : how could i get a vector with repeats of elements in cell ? for example if there are three 2 in the all elements of cell , in my vector index(2) i have 2 ? thanks a lot !.
  댓글 수: 2
Adam
Adam 2017년 8월 7일
편집: Adam 2017년 8월 7일
Convert C to numeric and use
doc ismember
The second question is basically just a histogram isn't it?
doc histogram
Hamid Salari
Hamid Salari 2017년 8월 7일
@Adam i will look into it . thanks .

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2017년 8월 7일
Use setdiff inside cellfun:
V = 1:100;
C = {randi(100, 1, 75)}; % Create ‘C’
Out = cellfun(@setdiff, {V}, C, 'Uni',0); % Use ‘setdiff’
Result = [Out{:}] % Dsiplay Result (Not Necessary For The Code)
  댓글 수: 4
Hamid Salari
Hamid Salari 2017년 8월 7일
@Star Strider. i got the idea behind it . thanks . my current cell is 1*12.
Star Strider
Star Strider 2017년 8월 7일
My pleasure.
My code should work with it as written.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by