How to use function structfind properly?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
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 Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!