Dimensions of arrays being concatenated are not consistent.

3 ビュー (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019 年 10 月 2 日
編集済み: Adam Danz 2019 年 10 月 4 日
I need to concatenate arrays that have variable length. All have 1 row but the number of columns are changing. Any suggestion?
Total_No_cells_r=[Total_No_cells_r;(total_cellcount_r)'];
  3 件のコメント
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019 年 10 月 2 日
Since this line is in a loop and it is calling an other script each time which gives error here is what I need to have. I have each column (total_cellcount_r(1), (total_cellcount_r(2), ...) ready and I want to concatenate them to do further calculation.
Capture.JPG
Adam Danz
Adam Danz 2019 年 10 月 4 日
編集済み: Adam Danz 2019 年 10 月 4 日
The problem seems to be missing data. If you fill in the missing data the vectors will be the same size and you can concatenate them as you wish.

サインインしてコメントする。

回答 (2 件)

James Tursa
James Tursa 2019 年 10 月 2 日
If they are all row vectors, then I would think something like this:
Total_No_cells_r = [Total_No_cells_r, total_cellcount_r];
If not, then you need to tell us what the sizes actually are.
  1 件のコメント
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019 年 10 月 2 日
As explained, the problem is that they dont have the same size and I get error.

サインインしてコメントする。


Star Strider
Star Strider 2019 年 10 月 2 日
編集済み: Star Strider 2019 年 10 月 2 日
If they all have one row and you want to concatenate them, the only certain way is to use the horzcat function.
If you want to concatenate them vertically, the easiest way would be to use a cell array.
EDIT —
For example, since ‘radius’ appears to be incrementing with a constant interval (and so can be used as an index counter):
Total_No_cells_r{radius} = [radius, total_cellcount_r(1), (total_cellcount_r(2), ...];
That would accommodate any number of columns in each row.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by