MATLAB: Finding the length of a pendulum in motion

image acquisitionimage processing

When i write the following code, for count = 1:nFrames lab = bwlabel(seg_pend(:, :, count)); property = regionprops(lab, 'Centroid'); pend_centers(count, 🙂 = property.Centroid; end i get an error of "too many outputs requested" how can i correct it?

Best Answer

property = regionprops(lab,'Centroid') returns a struct, the fields of which correspond to each ROI (blob) in lab. To convert the centroids of those ROIs into a vector, you might consider something like:
b = reshape([property.Centroid],2,[])';
and then write them en masse to pend_centers.
Or, inside of your for loop, consider writing:
pend_centers(count,:) = property(count).Centroid;
Cheers,
Brett