필터 지우기
필터 지우기

Accept or Reject

조회 수: 9 (최근 30일)
Frandy
Frandy 2012년 2월 17일
편집: unhappy 2013년 10월 15일
I am trying to write a script that allows me to accept or reject data, so would ginput work for that?

채택된 답변

Dr. Seis
Dr. Seis 2012년 2월 17일
Here is an example. I generate a random dataset, then I cycle through each subset of data and I enter an "A" for accepting the data OR a "R" to reject the data. At the end, a new dataset is created with only the accepted data.
data = rand(5,10); % generate 5 rows of random data
indices = 1:size(data,1); % initialize indices of data
figure;
for ii = 1 : size(data,1)
plot(data(ii,:));
[x,y,button] = ginput(1);
if button == 97 % A - for accept
disp('Input Accepted!');
elseif button == 114 % R - for reject
indices(ii) = 0;
disp('Input Rejected!');
else
disp('Button not recongnized!')
end
end
indices = indices(indices~=0); % Remove indices that were rejected
new_data = data(indices,:); % Create new dataset with only accepted data

추가 답변 (1개)

Dr. Seis
Dr. Seis 2012년 2월 17일
Yes. Search for "ginput" in your help navigator. You can even set it up so that pressing the button associated with "R" rejects the data and "A" accepts the data... though a quicker way may be to associate mouse button clicks with either rejecting or accepting data.
You can run some tests before hand to see what letters are associated with what button numbers. For example, hitting the "A" button when the blank figure pops up gives the following:
>> [x,y,button] = ginput(1)
x =
0.52189
y =
0.3348
button =
97
  댓글 수: 1
Frandy
Frandy 2012년 2월 17일
Thank you very much...but how exactly would you set it up so that "R" rejects and "A" accepts?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by