1
我想在另一個類系統in MATLAB. The class
Cell`是創建一個類Cell
的對象的數組:在另一個類中創建一個類的對象的數組MATLAB
classdef Cell
properties
ID;
EntityID;
ZoneID;
NeighborID;
State;
nextChangeTime;
end
methods
% Define the constructor
function obj = Cell()
obj.ID = zeros(1);
obj.EntityID = zeros(1);
obj.ZoneID = zeros(1);
obj.NeighborID = zeros(1);
obj.State = zeros(1);
obj.nextChangeTime = zeros(1);
end
end
現在我有另一個類System
。我儘量讓Cell
對象的數組,像這樣:
classdef System
properties
Cells;
end
methods
function obj = System(dimx,dimy)
obj.Cells(dimx,dimy) = Cell();
end
end
但我認爲我使用的格式不正確。不知道這是否可能。任何建議如何做到這一點將不勝感激。
所以我必須定義一個單元格默認構造函數。但是,當我嘗試執行語句'obj.Cells(dimx,dimy)= Cell();'它說轉換爲單元格的倍數是不可能的。 – Nitin 2013-04-20 20:34:00
我調整了代碼,請再看看我的帖子。顯然,空屬性的默認類型是雙精度型。我們需要將其更改爲Cell。 – 2013-04-20 20:49:44
謝謝。現在工作! – Nitin 2013-04-20 21:03:50