Looking to find data in a spreadsheet via user prompts
1 回表示 (過去 30 日間)
古いコメントを表示
So this is a basic example of the spreadsheet I'm using. Basically I want to prompt the user firstly for a P value (10-100 in steps of 10) and then a Q value (either 33 or -33). I know how to prompt the user for values and store these as variables but I then want to select the relevant test case (3001-3020) based on the values of P and Q and store it in a variable, lets say 'CurrentTestCase'. Does this make sense?
For example, lets say the user inputs P = 80 and Q = 33, I want my script to be able to select the testcase 3018 and store '3018' in the varuable 'CurrentTestCase'. Many thanks
0 件のコメント
回答 (1 件)
dpb
2022 年 9 月 21 日
編集済み: dpb
2022 年 9 月 21 日
For the above correlation (or any similar that is linear in the two variables), you can simply compute the case ID; you don't need a lookup--
fnCase=@(P,Q)3000+P/10+(10*(Q>0));
If it is more generic and/or can change in ways other than obvious modifications to the above that can be derived programmatically, then just read the table and do a lookup inside it...you don't try to find the data inside the spreadsheet itself, but work on the in-memory data of the table.
tCASEIDS=readtable('YourExcelFile.xlsx');
% input P,Q, here...
CurrentTestCase=tCASIDS.TestCases(tCASIDS.("P%")==P & tCASIDS.("Q%")==Q));
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!