【发布时间】:2016-01-28 14:46:14
【问题描述】:
我有一个循环,我想在其中创建一个对象。它必须为每个循环共享相同的名称。喜欢
for i=1:100
car=car(args(i))
%in this loop do stuff with car
end
问题在于,在第二次迭代中,matlab 尝试访问元素 car(args(i)) 而不是调用 car 类的构造函数。
这是 arg=SS 的错误
Error using subsindex
Function 'subsindex' is not defined for values of class 'SS'.
在 java 中,我会简单地调用 ''new'' 参数,比如
car=new car(args);
//do stuff with the car istance
car= new car(args);
//do stuff with the new car istance
我无法分配“汽车”数组,因为每个距离都有数百兆字节。我尝试在 matlab 中寻找类似于 new 的关键字,但没有运气。
【问题讨论】: