필터 지우기
필터 지우기

How can i find which value of a cell equals to 1?

조회 수: 11 (최근 30일)
Volkan Yangin
Volkan Yangin 2016년 10월 7일
댓글: Jakub Rysanek 2016년 10월 9일
Hi everbody,
I have a cell array includes [] and 1 elements and i want to find which cell equals to 1. (For ex. 220. cell equals 1.)
Thanks...

채택된 답변

Massimo Zanetti
Massimo Zanetti 2016년 10월 7일
If in your cell you have only [] or 1 elements, this works.
C={1,[],[],1,[],1}
%get indeces of 1s
OnesInC = find(~cell2mat(cellfun( @(x) isempty(x) , C , 'UniformOutput' , false )))
Otherwise, let me know.
  댓글 수: 2
Volkan Yangin
Volkan Yangin 2016년 10월 7일
It works succesfully. Thanks. :)
Jakub Rysanek
Jakub Rysanek 2016년 10월 9일
Or you can do it 20x times:
find(~cellfun('isempty',C));

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by