找回密码
 注册
关于网站域名变更的通知
查看: 3049|回复: 7
打印 上一主题 下一主题

请问Matlab怎样把元胞数组转化成矩阵?

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2020-5-8 10:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
Matlab里怎么把元胞数组的内容转化为矩阵?(元胞数组的每个元胞都是double型的数)。
. n' S  l+ T6 d4 I, ~3 f' N9 r5 {0 E

该用户从未签到

2#
发表于 2020-5-8 13:25 | 只看该作者
CELL2MAT Convert the contents of a cell array into a single matrix.( X0 C  L3 ^/ @+ B4 s8 Z
    M = CELL2MAT(C) converts a multidimensional cell array with contents of( A8 b7 T1 W4 X6 S$ S( y  p* s
    the same data type into a single matrix. The contents of C must be able) R8 A& Y5 L8 i6 m) M* Q
    to concatenate into a hyperrectangle. Moreover, for each pair of/ P  D) y! k7 @3 V  `! k
    neighboring cells, the dimensions of the cell's contents must match,+ M. W4 \4 @+ y, {
    excluding the dimension in which the cells are neighbors. This constraint
  z+ Q% _) V  U9 y0 S    must hold true for neighboring cells along all of the cell array's+ g; `6 \7 y  x4 w& V
    dimensions.
8 S. Z$ t) m. T3 O5 T1 F. e
% ?0 H( H) l/ Q2 i) O8 j    The dimensionality of M, i.e. the number of dimensions of M, will match% B) ]. g+ q3 I& h# W  G( {1 q( x
    the highest dimensionality contained in the cell array.1 Y+ Z# ?* o8 [0 h$ `7 S
4 {3 h0 _, W/ R1 i) q9 ?
    CELL2MAT is not supported for cell arrays containing cell arrays or
5 b9 S2 L* g1 D0 P    objects.+ V; q0 l4 \0 x2 p( t, j3 {* J
( I5 o) w& J) v1 n% K4 G
        Example:
! L" ^9 X5 ]9 x$ U. @- Y+ U           C = {[1] [2 3 4]; [5; 9] [6 7 8; 10 11 12]};$ s) i+ C5 e' [9 `& a& f
           M = cell2mat(C)
9 O' `- C0 ^: f- \, m  ]- {3 B
! x% J$ T4 C0 D" Y5 L8 t. N; Z$ n        See also mat2cell, num2cell
' r, `; k8 J& s/ w6 @
9 w' H3 Y7 K; d+ F    Overloaded methods:6 @3 e" H! _4 Q. d6 B
       distributed/cell2mat, e3 B+ \* q: A3 g+ }
. m. `5 r: U2 R( i; C( t' e( i1 @
    Reference page in Help browser
  t; e" {. }5 O3 f3 @2 {- @2 f       doc cell2mat

该用户从未签到

3#
发表于 2020-5-8 13:25 | 只看该作者
, F5 M- @' E0 ?$ b
help cell2mat

该用户从未签到

4#
发表于 2020-5-8 14:18 | 只看该作者
仔细看下mat2cell命令,不只能转化成1*1的cell。  }- n* e5 J2 Z1 P) S% g' |: v

: T+ b2 r$ w; |! i8 W5 O1 m$ en = 10;
: c3 Y' a& {3 w8 x$ s; L* k9 L+ r$ `a = rand(n);: u+ I8 G: _$ d2 Y
acell = mat2cell(a,ones(n,1),ones(n,1));

该用户从未签到

5#
发表于 2020-5-8 17:20 | 只看该作者
有问题就找help
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-6-25 16:18 , Processed in 0.078125 second(s), 23 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表