I’m doing a project in a University here in Brasil, and I’m using MatLab. I’m new in it, so I have to search a lot. A problem that’s disturbing me right now is that I need to store many Matrix of different sizes in a Array.
The code is:
for count = 1:nColors
i = rgb2gray(segmented_images(:,:,:,count));
bw = im2bw(i,0.01);
s = regionprops(bw,'Centroid');
centroids = cat(1, s.Centroid);
end
Centroids is a Matrix, and the size of it varies. I need to store it, so I can use later. I tried
centroids(count) = cat(1, s.Centroid);
but MatLab said “In an assignment A(I) = B, the number of elements in B and
I must be the same.”
You need a cell array: http://www.mathworks.co.uk/help/techdoc/matlab_prog/br04bw6-98.html