Reputation: 885
I am so new with Matlab. I have one dimension array Table_cluster.I am working in wireless sensor networks. So my concept is that all nodes will send data to associated cluster head.Cluster head will aggregate them.
Suppose
There are 5 nodes which are associated with cluster head 11.And each node will send 256 bytes of data.So cluster head will get 5*256 bytes data.I need to aggregate it.
This will apply to all 100 nodes and their associated cluster heads.
Now suppose
node 1 is associated with cluster head 11.
node 2 with cluster head 12.
node 3 with cluster head 11.
node 4 with cluster head 11.
node 5 with cluster head 12.
What I need is to maintain array such as
Table_cluster(11)={1,2....,3*256} %% 1,2,...,3*256 indicates position . Data can be any.
Table_cluster(12)={1,2....,2*256}
I tried to find out that how can I convert position of array in another array which holds dynamic size.But I can not find it out.
So please help or suggest me any other way to achieve my concept.
Upvotes: 0
Views: 254
Reputation: 6824
If I understood your problem correctly, you need to store arrays into another array. This means your Table_cluster
is going to be a cell array.
Inside your table cluster, you can store a cell of 2D arrays. In your case, the 2D arrays are actually of size 1x256 2x256, etc. (if I understand right). This is where your Cluster heads are aggregating them. To do this, you need to read about MATLAB cell arrays and how to index them. As @Divakar pointed out in his comment, the cell array indexing is different than that of a 1-D or 2D array. You have {} braces to do the indexing.
Upvotes: 1