How to integrate 6 different variables into a struct?

1 回表示 (過去 30 日間)
Metin Ertas
Metin Ertas 2014 年 2 月 19 日
コメント済み: Metin Ertas 2014 年 2 月 19 日
I need a help on a very specific problem:
Assume that we have 6 variables and each has got different number of elements such as;
A=[1 2]; B=[1 2 3 4]; C=[]; D=[1 3 4 5 6]; E=[1]; F=[0 0 0 ];
I wan to keep them in a format like this:
New_form(: , i , j)
i represents the first three variables A, B and C j represents the last three variables D, E and F
when I wanted to call `D` for examples Newform(:,2,2) should be written.
The question is obvious: All variables have got different sizes and in mamtrix form it s no possible. But I am sure there must be a way to do it by using `struct` .But I couldnt ve managed to do it.

採用された回答

Mischa Kim
Mischa Kim 2014 年 2 月 19 日
編集済み: Mischa Kim 2014 年 2 月 19 日
Metin, you could simply use a cell array. As an example:
New_form = {A D; B E; C F};
In this case D is accessed as
New_form{1,2}
first row, second column.
  1 件のコメント
Metin Ertas
Metin Ertas 2014 年 2 月 19 日
It worked perfect to my need. Thanks

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by