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

12 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

John D'Errico
John D'Errico am 24 Okt. 2020
Bearbeitet: John D'Errico am 24 Okt. 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.
squeeze(INFO(2,7,:))
ans = 4×1
5 1000 20 100
INFO(2,7,1)
ans = 5
INFO(2,7,2)
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 Kommentar
Shakeel alvi
Shakeel alvi am 24 Okt. 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing 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!

Translated by