How to use function structfind properly?

1 view (last 30 days)
John
John on 14 Mar 2015
Commented: Geoff Hayes on 14 Mar 2015
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 Comment
Geoff Hayes
Geoff Hayes on 14 Mar 2015
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?

Sign in to comment.

Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!