Reference to a variable
15 ビュー (過去 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!