0

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.

6
  • Your examples are not quite clear to me. I understand that 1*256 means it's a position. "Data can be any" what does it mean? Commented Feb 25, 2015 at 11:48
  • Means 3*256 are the positions and those positions can contain any numeric data. Commented Feb 25, 2015 at 11:50
  • okay. So you want to create arrays which are of size 3*256, 1*256 etc.? From Table_cluster(11). Also, how are you getting the all the positions i mean where are you currently storing it? In an array or cell? Commented Feb 25, 2015 at 11:51
  • Yes.But not from Table_cluster(11),To Table_cluster(11). Because any clusterhead has any numbers of nodes and each node will send 256 bytes of data. So if cluster head is 11 and it has 3 nodes than It will get 3*256 bytes . So I need to that Table_cluster(11) will hold {1,2,3.... upto.....3*256}. Commented Feb 25, 2015 at 11:55
  • In my case I am using one loop such from 1 to 100 nodes. In that loop I am getting data in one array of 256 bytes. Then I have to send to cluster head.Which will aggregate data from all associated nodes. Commented Feb 25, 2015 at 11:57

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.