MATLAB Answers

How to create a 6 dimension array in Matlab and store values in it

2 views (last 30 days)
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


Sign in to comment.

Accepted Answer

John D'Errico
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;
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.
ans = 4×1
5 1000 20 100
ans = 5
ans = 1000
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.

  1 Comment

Shakeel alvi
Shakeel alvi on 24 Oct 2020
Thanks a lot , this info is very useful.
One more help . now if we have to assign for 10 different ( x,y) coordinates , 4-each different values . then what to do

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by