Find row and collumnumber in matrix.

3 ビュー (過去 30 日間)
Daan
Daan 2015 年 10 月 21 日
編集済み: Thorsten 2015 年 10 月 21 日
Hi all,
I have got a cell array with cells of different lengths: A=[0,0,0,0],[0],[0],[1],[0] and I would like to know the location of 1. When I use
c = find([a{:}] == 1); I get 7, instead of 4. How can I find the location of the 1?
Thanks, Daan

採用された回答

Thorsten
Thorsten 2015 年 10 月 21 日
編集済み: Thorsten 2015 年 10 月 21 日
This finds cells that contain a 1, maybe amongst other numbers:
find(cell2mat(cellfun(@(x) (any(x==1)), C, 'UniformOutput', false)))
This looks for a single 1
find(cell2mat(cellfun(@(x) (isequal(x,1)), C, 'UniformOutput', false)))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by