LoginSignup
2
2

More than 5 years have passed since last update.

ネスト化されたcellをアンネストする

Posted at

c={{1,2,3},{4,5,6,7}}

といったようにネスト化されたcellを,

d={1,2,3,4,5,6,7}

とアンネストすることを考える.この場合,

>> d=[c{:}]
d = 
    [1]    [2]    [3]    [4]    [5]    [6]    [7]

として簡単に書けることが知られている.ところが,

c_vert={{1;2;3};{4;5;6;7}}

と垂直方向にセルが並んでいる場合,

>> d_vert=[c_vert{:}]
Error using horzcat
CAT arguments dimensions are not consistent.

とエラーを吐かれてしまいうまくいかない.これは,[]を使った結合では水平方向の結合(horzcat)がデフォルトで呼ばれてしまうためである.
このような場合,vertcatコマンドを使う.

>> d_vert=vertcat(c_vert{:})
d_vert = 
    [1]
    [2]
    [3]
    [4]
    [5]
    [6]
    [7]
2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2