この例のオブジェクトの場合:
classdef TestObject < handle
%UNTITLED Summary of this class goes here
% Detailed explanation goes here
properties
a;
end
methods
end
end
およびこのスクリプト例:
tbarray = TestObject.empty();
for i=1:3
newTestObject=TestObject;
newTestObject.a=i;
if(i==1)
firstTestObject=newTestObject;
end
tbarray(end+1,1)=newTestObject;
end
delete (firstTestObject) ;
これが実行された後、tbarray の最初の位置には空の TestObject があります。tbarray のサイズを変更したり、空のオブジェクトを削除したり、何らかの削除呼び出しを使用したりすることは可能ですか?
index=tbarray.remove(firstObject);
tbarray.add(index,laterTestObject);
またtbarray.Replace(firstObject,laterObject);
更新: 削除/置換するオブジェクトの配列インデックスを見つけるにはどうすればよいですか。この例では 1 を使用していますが、毎回異なる場合があります。