我有一个循环,我想在其中创建一个对象.它必须为每个循环共享相同的名称.喜欢
for i=1:100
car=car(args(i))
%in this loop do stuff with car
end
Run Code Online (Sandbox Code Playgroud)
问题是在第二次迭代时,matlab尝试访问元素car(args(i)),而不是调用class car的costructor.
这是arg = SS的错误
Error using subsindex
Function 'subsindex' is not defined for values of class 'SS'.
Run Code Online (Sandbox Code Playgroud)
在java中,我只需调用''new''参数,就像
car=new car(args);
//do stuff with the car istance
car= new car(args);
//do stuff with the new car istance
Run Code Online (Sandbox Code Playgroud)
我不能分配一个''汽车'数组,因为每个数字都是几百兆字节.我尝试在matlab中寻找类似于new的关键字,但我没有运气.