How to create a 6 dimension array in Matlab and store values in it
14 views (last 30 days)
Show older comments
Shakeel alvi
on 24 Oct 2020
Commented: Shakeel alvi
on 24 Oct 2020
I have 8-relay , which i want to represent by x and y coordinates , then store 4 attribues of each of these relay , these attribues are generated randomly
for example relay no 1. at x=2 and y=7 ,
has power =5,
buffer total =1000, SINR=20 ,
Packets in buffer = 100
0 Comments
Accepted Answer
John D'Errico
on 24 Oct 2020
Edited: John D'Errico
on 24 Oct 2020
It very much depends on what you want to do with that data. But I think you are looking for a very inefficient way to store your information.
You might, for example, use a THREE dimensional array.
x = 2;
y = 7;
INFO(x,y,[1:4]) = [5 1000 20 100];
So in the (2,7) location, we see the data has been stored as desired.
squeeze(INFO(2,7,:))
INFO(2,7,1)
INFO(2,7,2)
So no need to think about 6 dimensions.
Another idea, is to treat a 2-d array as essentially a database.
INFO = [2 7 5 1000 20 100];
So each row of INFO is one piece of information. You can now sort things on any of the variables.
Perhaps better yet is to use a table. Now you can name the variables. Or, you could use structs. The point is, there are so many ways you can store the data, that do not force you to create 6 dimensional arrays.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!