java - how can I overwrite an object in matlab? -
i have loop in want create object. must share same name each loop. like
for i=1:100 car=car(args(i)) %in loop stuff car end
the problem @ second iteration matlab tries access element car(args(i)) instead of calling costructor of class car.
this error arg=ss
error using subsindex function 'subsindex' not defined values of class 'ss'.
in java i'd call ''new'' parameter, like
car=new car(args); //do stuff car istance car= new car(args); //do stuff new car istance
i can't allocate array of ''car'' since each istance several hundreds of megabytes. tried looking keyword similar new in matlab had no luck.
the problem you're calling variable same name class. first time define car=car();
, car
starts refer instance, rather class, , subsequent calls car()
not call class constructor, try access index of object car
(as if array, hence error subsindex
).
you have careful in matlab not shadow built-in function names, or in case, class name. in java, arrays accessed square brackets (i guess?), there's no ambiguity.
so, don't use car
name of instance of class car
. call mycar=car(args(i))
instead.
Comments
Post a Comment