Filter löschen
Filter löschen

Looking to find data in a spreadsheet via user prompts

2 Ansichten (letzte 30 Tage)
Paul
Paul am 21 Sep. 2022
Bearbeitet: dpb am 21 Sep. 2022
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

Antworten (1)

dpb
dpb am 21 Sep. 2022
Bearbeitet: dpb am 21 Sep. 2022
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));

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by