transforming cells having multi-dimensional matrics to 2-dimensional matrix.

1 次查看(过去 30 天)
Hi all,
I have a cell named Z whose elemnts are 3-dimensional matrixs as following:
z{1,1}=ones(nsm,nr, num_class)*10;
z{1,2}=ones(nsm,nr, num_class)*15;
z{1,3}=ones(nsm,nr, num_class)*20;
z{2,1}=ones(nsm,nr, num_class)*100;
z{2,2}=ones(nsm,nr, num_class)*150;
z{2,3}=ones(nsm,nr, num_class)*200;
I want to put together all members of Z and form a matrix named ZZ, like below:
ZZ=[10 10 10 15 15 15 20 20 20;
10 10 10 15 15 15 20 20 20;
10 10 10 15 15 15 20 20 20;
10 10 10 15 15 15 20 20 20;
100 100 100 150 150 150 200 200 200;
100 100 100 150 150 150 200 200 200;
100 100 100 150 150 150 200 200 200;
100 100 100 150 150 150 200 200 200;];
How can I do it. Any help would be appreciated.
Thanks in advance.

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-10-13
nsm=4,
nr=3,
num_class=2
z{1,1}=ones(nsm,nr, num_class)*10;
z{1,2}=ones(nsm,nr, num_class)*15;
z{1,3}=ones(nsm,nr, num_class)*20;
z{2,1}=ones(nsm,nr, num_class)*100;
z{2,2}=ones(nsm,nr, num_class)*150;
z{2,3}=ones(nsm,nr, num_class)*200;
zz=cell2mat(z)

类别

Help CenterFile Exchange 中查找有关 Agriculture 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by