how to use find to cell cell indexing

조회 수: 1 (최근 30일)
RuiQi
RuiQi 2016년 12월 10일
편집: RuiQi 2016년 12월 10일
why does this not work ?
find(grnd_truth_cell{:,1} == 6)
I want to find all of grnd_truth_cell whose 1st column at every row == 6 but matlab tell me Error using == Too many input arguments.
  댓글 수: 2
Image Analyst
Image Analyst 2016년 12월 10일
If you just type this on the command line
grnd_truth_cell{:,1}
what does it report to the command window? Show us.
RuiQi
RuiQi 2016년 12월 10일
These are the last few numbers. It goes from 0 to 7480
ans =
7480
ans =
7480
ans =
7480
ans =
7480

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

채택된 답변

dpb
dpb 2016년 12월 10일
Because as your command line shows,
grnd_truth_cell{:,1}
is a comma-separated list. Enclose it in the [] to make an array that find can operate over--
find([grnd_truth_cell{:,1}]==6)
  댓글 수: 1
RuiQi
RuiQi 2016년 12월 10일
편집: RuiQi 2016년 12월 10일
thank you and imageanalyst, i learnt how to handle 'comma-separated lists' today using []

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

추가 답변 (1개)

Image Analyst
Image Analyst 2016년 12월 10일
편집: Image Analyst 2016년 12월 10일
Maybe you can assign it to a column vector first
col1 = grnd_truth_cell{:,1};
whos col1
rowsThatEqual6 = find(col1 == 6); % Braces.
How does that work? Maybe you need to use cell2mat():
col1 = cell2mat(grnd_truth_cell(:, 1)); % Parentheses
If that doesn't work, attach grnd_truth_cell in a .mat file so I can try some things.
save('grnd_truth_cell.mat', 'grnd_truth_cell');
And please read the FAQ on cell arrays: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by