why overwrite cell in loop matlab?

7 次查看(过去 30 天)
jenifer Ask
jenifer Ask 2019-12-26
评论: jenifer Ask 2019-12-26
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
maaathw.PNG
  2 个评论
Image Analyst
Image Analyst 2019-12-26
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?
jenifer Ask
jenifer Ask 2019-12-26
'Why are you not using pdist2()? Do you not have the stats toolbox?'
I used But out put matrix have different calculate distance
for example, result for one image with D = pdist2(x1,y1,'euclidean'); (picture 2) . and mycode (picture 1)
mycode.jpg
pdist.jpg

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by