Reference to a variable
13 次查看(过去 30 天)
显示 更早的评论
hi, I am loading a huge amount of data into a database. The database is dynamic and sometimes will hold 50 separate entities and sometime less. Each entity than has a list of up to 10,000 separate variables, each of which is a table of values. I need a way to hold pointers (or references) to the variables to ease later scanning of the database of only particular data. I don't know in advance the number of items in each entity or the number of entities. I was thinking using whos and/or fieldnames to scan the database and get a complete list of all the variable names. But once I have the reference (for example as a string of the var name) how to I access that variable's value? For example if there is a variable called David and its value is 7, and if I have a string 'David', how can I get the value from the string?
0 个评论
采纳的回答
Jan
2011-5-4
What exactly is "a database"? Do you mean a database?
The last sentence of your question sounds like you want to use dynamic fieldnames:
Data.Field1 = rand(3)
Name = 'Field1';
Index = {2, 3}
disp(Data.(Name)(Index{:}))
But the initial part of the question let me assume, that you better use a database program.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!