soooooo, if you use a java constructor in the matlab interpreter (say an arraylist), and follow it with a method call (say toArray()), matlab will happily parse, comprehend, and execute your line of code. for instance, extracting things from a hashmap:

>> vs = java.util.ArrayList(m.values()).toArray();

if you copy-paste that line of code into a script and run the script, the matlab interpreter will happily parse and comprehend your code, then throw an error telling you not to do it. no particular reason given, just not allowed.

??? Static method or constructor invocations cannot be indexed.
Do not follow the call to the static method or constructor with any additional indexing or dot references.

Error in ==> plotExtracted at 2
vs = java.util.ArrayList(m.values()).toArray();

hatehatehatematlab >:(

3 Responses to “hateyhatey”

  1. cakesniffer says:

    OOo, you’re already number five in the results list for that error message!

  2. Fayssal El Moufatich says:

    I have also encountered the same problem chaining function calls on MATLAB objects. You can also avoid this issue if you “eval” to evaluate your call.

  3. petejonze says:

    I also feel your pain =(

    The really odd bit is that it will happily execute in Cell Mode, and only throws a tantrum when you run normally.

    Thanks to Fayssal for the eval hack.