How to use function structfind properly?

1 次查看(过去 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
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