필터 지우기
필터 지우기

How to use function structfind properly?

조회 수: 3 (최근 30일)
John
John 2015년 3월 14일
댓글: Geoff Hayes 2015년 3월 14일
Hello:
When I test structfind ( http://www.mathworks.com/matlabcentral/fileexchange/29808-structfind ), it's working fine. See:
% test run
structfind(object,'pixels',[6 6])
ans =
1
structfind(object,'pixels',[sy sx])
ans =
1
However, inside my code, the function is returning errors. I'm not sure why. See:
% inside the code
sym1 = sy-1; sxm1 = sx-1;
seedIntensity = originalx(sy,sx);
d1 = abs(seedIntensity - originalx(sym1,sxm1));
inObject = structfind(object(w),'pixels',[sym1,sxm1]);
if (d1 < avgInt && isempty(inObject) == 1)
object(w).pixels = [object(w).pixels; sym1 sxm1];
end
Error using == Matrix dimensions must agree.
Error in cmp (line 31) check=all(x==value);
Error in structfind>@(x)(cmp(x,field,value)) (line 88) index=find(arrayfun(@(x)(cmp(x,field,value)),a,'uniformoutput',true));
Error in structfind (line 88) index=find(arrayfun(@(x)(cmp(x,field,value)),a,'uniformoutput',true))
Where originalx is a 2-D array. Can someone help me troubleshoot?
  댓글 수: 1
Geoff Hayes
Geoff Hayes 2015년 3월 14일
John - put a breakpoint at the line
inObject = structfind(object(w),'pixels',[sym1,sxm1]);
and run your code. When the debugger pauses at the above line, look at each input. What is object(w), what is sym1, what is sxm1?

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

답변 (0개)

카테고리

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