Array formation and parentheses-style indexing with objects of class 'nodeClass' is not allowed. Use objects of class 'nodeClass' only as scalars or use a cell array.
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aditya Patil
am 15 Mai 2021
Beantwortet: Steven Lord
am 24 Mai 2021
I have extended the helperPacketizedModemNode class to nodeClass with 2 properties
classdef nodeClass < helperPacketizedModemNode
properties
Energy = 100
isClusterHead = true
end
methods
function obj = nodeClass(addr)
obj.Address = addr;
obj.DestinationList = 0;
obj.Energy = 100;
obj.isClusterHead = true;
obj.NumPayloadBits = 19530;
obj.PacketArrivalRate= 0.2;
obj.ACKTimeOut = 0.25;
obj.MaxBackoffTime = 10;
obj.MaxDataRetries = 5;
obj.QueueSize = 10;
obj.CarrierDetectorThreshold = 1e-5;
obj.AGCMaxPowerGain = 65;
obj.SamplesPerFrame = 2000;
obj.Verbose = true;
obj.SampleRate = 200e3;
end
end
end
for i = 1:5
node(i) = nodeClass(1);
end
0 Kommentare
Akzeptierte Antwort
Shiva Kalyan Diwakaruni
am 24 Mai 2021
Hi,
You can try replacing node(i) with node{i} to store object .
You can refer to below link for more information
Hope it helps
0 Kommentare
Weitere Antworten (1)
Steven Lord
am 24 Mai 2021
The helperPacketizedModemNode class used in, among other places, this example specifically disallows being stored as a non-scalar array of objects. You can create a scalar helperPacketizedModemNode object or you could create a cell array of helperPacketizedModemNode objects but you cannot create (as you're trying to do) a 5 element array of them.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Construct and Work with Object Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!