MATLAB: Implementation of array of queues

arrayMATLABqueue

Since matlab does not support queues, I am using arrays to handle the queueing functionality.
I have to implement an array of queues, which each queue of different length. 2D arrays in matlab support only matrices, hence should be of same no. of elements in each queue which is not my requirement.
I imported Java implementation of linkedlist, but it does not support struct or a class object. The element to be added into a queue is a struct or a class object.
How can I handle this in the most efficient way?

Best Answer

Standard arrays must be rectangular. However cell arrays are the perfect solution.
C = {1:3, 1:5,1:8}
C =
1×3 cell array
{1×3 double} {1×5 double} {1×8 double}
>> C{:}
ans =
1 2 3
ans =
1 2 3 4 5
ans =
1 2 3 4 5 6 7 8
You create and index them using curly braces, thus {}.
C{3}
ans =
1 2 3 4 5 6 7 8
And a cell array can contain anything at all, including structs.
Of course, an array of structs is also possible, and a struct can act as a container for anything too.