Filter löschen
Filter löschen


Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

fix a center of gravity loop

2 Ansichten (letzte 30 Tage)
BA am 27 Jul. 2022
Geschlossen: Image Analyst am 28 Jul. 2022
%identify axes
[x, y] = ginput(2);
% preallocate matrices
cog = zeros(size(matrix,3),1);
% the loop does not work and the error in the cog(i) line
% loop start
for i = 1:size(matrix,3)
I = matrix(:,:,i);
test = improfile(I,[x(1) x(2)],[y(1) y(2)]);
%the error comes from this line
cog(i) = sum((1:length(test)).*test)/sum(test);
% loop end
scog = (cog - min(cog)) / (max(cog) - min(cog));
  1 Kommentar
Matt J
Matt J am 27 Jul. 2022
You need to demonstrate the code and show us the error messages.

Akzeptierte Antwort

David Hill
David Hill am 27 Jul. 2022
cog(i) = sum((1:length(test)).*test')/sum(test); %need to transpose test' to match dimensions
  1 Kommentar
BA am 27 Jul. 2022
Bearbeitet: BA am 27 Jul. 2022
Fab. it works perfectly. I have another question: what is the equivalent of 'improfile' in octave? I mean to change the 'improfile' line to work in octave

Weitere Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by