MATLAB linked list

MATLAB has access to Java:

>> a=java.util.LinkedList;
>> li=a.listIterator;
>> li.add(2);
>> li.add(int8(77));
>> li.add(77);
>> li.add(boolean(true));
>> li.add('Mr. Bill');
>> li.previous();
>> li.add([1 2 3 4 5]);
>> a

a =

[2.0, 77, 77.0, true, [D@66a917, Mr. Bill]

>> a.get(4)

ans =

     1
     2
     3
     4
     5

The one downside of this approach is because MATLAB doesn’t have a way to marshal or serialize arbitrary MATLAB objects into Java, you’re limited to floating point numbers, integers (need to cast them in MATLAB using int8 etc.), booleans, strings, arrays, and Java objects.

Leave a Comment