2011-09-26 49 views
0

我正在巴西的一所大学做一个项目,我正在使用MatLab。我是新手,所以我必须搜索很多。现在令我感到困扰的一个问题是,我需要将许多不同大小的Matrix存储在Array中。 的代码是:有可能在Matlab中做一个矩阵数组?

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(count) = cat(1, s.Centroid); 

但MatLab的说, “在一个分配A(I)= B,B中的元素的 数目和我必须是相同的。”

回答

1
for count = 1:nColors 
i = rgb2gray(segmented_images(:,:,:,count)); 
bw = im2bw(i,0.01); 
s = regionprops(bw,'Centroid'); 
centroids(i).matrix = cat(1, s.Centroid); 
end