Best data structure to use?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello All,
I have some experience with programming but I'm very new to Matlab.
Could anyone recommend the best data structure to use for my requirements?
I basically want to represent an agent which has the following attributes: identifier (simple string will do), x position and y position. I will have up to 10 of these. I'll need to update the positions on a regular basis.
Many Thanks in advance.
0 commentaires
Réponses (2)
Image Analyst
le 16 Jan 2014
I'd probably use a structure array :
agentNumber = 8; % Whichever...
agent(agentNumber).id = 'whatever';
agent(agentNumber).x = 42;
agent(agentNumber).y = 123;
It may be faster to use a 2D array for x and y and the "agentnumber" is the row, and a cell array or character array for the strings. For only 10 agents, speed is not an issue. If you have millions of them then you may want to experiment with different ways of doing it.
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!