How to integrate 6 different variables into a struct?

2 views (last 30 days)
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.

Accepted Answer

Mischa Kim
Mischa Kim on 19 Feb 2014
Edited: Mischa Kim on 19 Feb 2014
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.

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!