Filter löschen
Filter löschen

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

9 Ansichten (letzte 30 Tage)
Volkan Yangin
Volkan Yangin am 7 Okt. 2016
Kommentiert: Jakub Rysanek am 9 Okt. 2016
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...

Akzeptierte Antwort

Massimo Zanetti
Massimo Zanetti am 7 Okt. 2016
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 Kommentare
Volkan Yangin
Volkan Yangin am 7 Okt. 2016
It works succesfully. Thanks. :)
Jakub Rysanek
Jakub Rysanek am 9 Okt. 2016
Or you can do it 20x times:
find(~cellfun('isempty',C));

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by