Comparing user input and dataset to select appropiate value
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Hugo
2013년 6월 10일
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
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!