0

I was trying to use a list in matlab and I found this post:MATLAB linked list

it seems like matlab can use java. given that I do

 a=java.util.linkedList;
 a.add(2);
 a.add(3);
 a.add(5);

and I get in a the 3 elements. The problem comes when I want to remove one of them. Let's say I want to remove 2.

if I cast

 a.remove(2)

matlab removes me 5,since it sees 2 as an index. In java I'd cast the int to Integers,but I can't manage to do it in Matlab (I can't even use the constructor, in java I'd do linkedList<Integer> a=new linkedList<Integer>() and then cast 2 to Integer and it should work)

is there any way I can solve this issue?

Community
  • 1
  • 1
user1834153
  • 330
  • 5
  • 20
  • I guess I could use a listIterator,search for the element, use previous() and then set next() to next().next() but it seems a bit too much for just removing one entry. – user1834153 May 05 '14 at 18:09
  • and the iterator doen't work because I can't check if an element is equal to an int since the element is probably a java object. – user1834153 May 05 '14 at 18:28

0 Answers0