Best data structure to use?
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Image Analyst
2014 年 1 月 16 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!