在Matlab中可以做一个矩阵数组吗? [英] It's possible to do a array of Matrix in Matlab?

查看:138
本文介绍了在Matlab中可以做一个矩阵数组吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在巴西的一所大学里做一个项目,并且正在使用MatLab.我是新手,因此我必须进行大量搜索.现在困扰我的一个问题是,我需要在一个数组中存储许多不同大小的矩阵. 代码是:

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);

但是MatLab表示在赋值A(I)= B中,B中的元素数和 我必须一样."

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

这篇关于在Matlab中可以做一个矩阵数组吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆