Info
This question is closed. Reopen it to edit or answer.
Something funny with Cell Array
2 views (last 30 days)
Show older comments
for l=1:dn
bw3 = (dl==l);
[xleft2,xright2,yup2,ydown2] = extract(~bw3);
width2 = xright2-xleft2+1;
height2 = ydown2-yup2;
extractnote=imcrop(bw3,[xleft2,yup2,width2,height2]);
outer_box2 = prop2(l).BoundingBox;
ul_corner_x2 = outer_box2(1);
ul_corner_y2 = outer_box2(2);
box_width2 = outer_box2(3);
box_height2 = outer_box2(4);
notePos=outer_box(2)+outer_box2(2)+(d/2);
noteFromLastline = lastlineF-notePos;
finalnote = pitch(d,gap,noteFromLastline);
output(l) = {finalnote};
end
Hi peeps,
Basically, for the above code I am note getting a filled cell array back.
finalnote gives my n chars back with each looping (i.e. 'A' etc...), but when I add the chars into the output cell array with each loop, at the end I just get an almost empty output cell array with only the first two items filled. This is what I get but I suppose to get all those cells filled. Any help or advice will be greatly appreciated. Thanks.
output =
Columns 1 through 11
'A' 'A' [] [] [] [] [] [] [] [] []
Columns 12 through 22
[] [] [] [] [] [] [] [] [] [] []
Columns 23 through 33
[] [] [] [] [] [] [] [] [] [] []
Columns 34 through 44
[] [] [] [] [] [] [] [] [] [] []
Columns 45 through 46
[] []
3 Comments
Image Analyst
on 20 Apr 2013
Too much work for me to analyze, especially without an image, the lack of which prevents me from running your code and replicating your problem. Have you seen this: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/. Careful debugging on your part will solve this quickly and easily. That is a much more effective route to take than asking us.
Answers (1)
Walter Roberson
on 20 Apr 2013
You have "for p = 1 : n", and inside that loop you have a nested loop "for p = 1 : dn". Therefore inside the nested loop, p in the sense of "for p = 1 : n" has its meaning suspended.
Note: if you are looping to n, and inside that you can potentially find multiple objects, then the total number of objects you can find will be more then n. How do you want to deal with that?
0 Comments
This question is closed.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!