フィルターのクリア

Create a cell from a matrix

2 ビュー (過去 30 日間)
Marc Gebhardt
Marc Gebhardt 2017 年 11 月 13 日
コメント済み: Marc Gebhardt 2017 年 11 月 13 日
Dear community, my problem seems to be quite easy, but i didnt solved it until now.
I have to vectors of size n*1 arranged in a matrix.
mat1=[1,2,3,4,5;0,0,1,0,1]
This matrix is loaded from another workspace. My gain is, to arrange them with only one command in an 2x1 cell, in which the field {1,1} is the first vector, and field {2,1} is the second vector.
This should work also for many rows more. I tried
a={mat1}
But this puts all in the 1x1 cell field. How can I solve this? Thanks Marc

採用された回答

KSSV
KSSV 2017 年 11 月 13 日
編集済み: KSSV 2017 年 11 月 13 日
C1 = num2cell(mymatrix,2)
This works for any 2D dimension of matrix..
  1 件のコメント
Marc Gebhardt
Marc Gebhardt 2017 年 11 月 13 日
Thanks.Works. It was soooo easy :D

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

その他の回答 (1 件)

KL
KL 2017 年 11 月 13 日
編集済み: KL 2017 年 11 月 13 日
If you want to have each row in separate cells,
mat1=[1,2,3,4,5;0,0,1,0,1];
C1 = arrayfun(@(x) {mat1(x,:)},1:size(mat1,1))
C =
1×2 cell array
[1×5 double] [1×5 double]
  1 件のコメント
Marc Gebhardt
Marc Gebhardt 2017 年 11 月 13 日
Thanks.

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

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by