Comparing user input and dataset to select appropiate value
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am writing a script which users can run to analyze their data. It involves a point where user input is required, because measurements have been made on different settings. I know how to ask for user input, but how can I compare the answer to my dataset and then select the appropiate value?
The relevant part of the script is:
prompt = {'Gemeten bij pompstand:','Tijd bij steady state in seconden:'};
dlg_title = 'Input';
num_lines = 1;
def = {'0.8','700'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
The dataset is as the following. answer(2,1) can just be a numeric value, I don't have a dataset for that one. Only answer(1,1) has to be compared and selected.
0.2 450
0.4 420
0.8 380
1.0 350
1.5 320
Thanks in advance,
0 Kommentare
Akzeptierte Antwort
Hugo
am 10 Jun. 2013
How about using find after conversion to numeric value of the answer?
ansnum=str2num(answer(1,1));
k=find(dataset==ansnum);
When dataset is the first column of the data that you show, k will give you the position where the user input matches the dataset.
Best regards,
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!