Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?