why overwrite cell in loop matlab?
1 view (last 30 days)
Show older comments
Hi
I try to calculate the distance of some picture, But on this Code, just remain the matrix distance of final picture.
Of course I see By F10 each output of distance of the points x1{i},y1{i} of the picture
image 1 have 15 points
image 2 have 22 points
image 3 have 18 points,... and mage 6, have 47 points,
this picture, result showed run my code that remain the matrix distance of final image.
vecPoint{i}=[x1{i},y1{i}];
[m{i} n{i}] = size(vecPoint{i});
n{i} = m{i};
Dist{i} = zeros(m{i}, n{i});
for ii = 2 : m{i}
for jj = 2 : n{i}
%%%%%%%%%%%%%%% Here %%%%%%%%%%%%%%%%%%%%%%%%%
Dist{jj,ii} = sqrt((vecPoint{i}(ii, 1) - vecPoint{i}(jj, 1)) ^ 2 + ...
(vecPoint{i}(ii, 2) - vecPoint{i}(jj, 2)) ^ 2);
end
end
2 Comments
Image Analyst
on 26 Dec 2019
Well it's doing what you're telling it to do. But what I don't know, is what you want it to do. What value does the poorly-named "i" have? Is that the loop iterator over images from 1 to 6? So all of that code is actually part of the inside of a loop over i? Why are you not using pdist2()? Do you not have the stats toolbox?
Answers (0)
See Also
Categories
Find more on Read, Write, and Modify Image 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!