An interactive plot for classifying data!

조회 수: 1 (최근 30일)
Wookie
Wookie 2022년 1월 13일
답변: Wookie 2022년 1월 22일
I am working with 3 matrices (Data1, Data2, Data3) where each row from each of the 3 matrices is a signal from the same time. I am attempting to have an interactive UI where the user can click if there's an abnormally or not. The code should record the answer from the toggle switch and plot the next 3 graphs until there's no more data.
I have two main issues:
  1. When pressing the toggle button, it will stay toggled until pressed again to untoggle before pressing the next anwer. It should untoggle--
  2. The recorded answer 'Result' gets erased on every iteration and I am not sure why!
Here is my code so far:
Results = table();
for ii = 1:10
pushbuttonPlot(Data1,Data2,Data3,ii)
waitforbuttonpress
end
function pushbuttonPlot(Data1,Data2,Data3,ii)
f = figure(1);
c = uicontrol('Position',[10 60 60 22]); %left, bottom, width, height
c.String = 'Abnormal';
c.Callback = @plotJointNext;
c2 = uicontrol('Position',[11+140 60 60 22]);
c2.String = 'Normal!!';
c2.Callback = @plotNoJointNext;
waitforbuttonpress
function plotJointNext(src,event)
figure(1)
subplot(3,1,1)
ylabel('Height (mm)')
plot(Data1((ii),:))
title(['Data 1, Index # ',num2str((ii))])
xlabel(' Points ')
subplot(3,1,2)
plot(Data2((ii),:))
ylabel('Height (mm)')
title(['Data 2, Index # ',num2str((ii))])
xlabel(' Points ')
subplot(3,1,3)
plot(Data3((ii),:))
ylabel('Height (mm)')
title(['Data 3, Index # ',num2str((ii))])
xlabel(' Points ')
Results(ii,:) = {('Abnormal')}
end
function plotNoJointNext(src,event)
figure(1)
subplot(3,1,1)
ylabel('Height (mm)')
plot(Data1((ii),:))
title(['Data 1, Index # ',num2str((ii))])
xlabel(' Points ')
subplot(3,1,2)
plot(Data2((ii),:))
ylabel('Height (mm)')
title(['Data 2, Index # ',num2str((ii))])
xlabel(' Points ')
subplot(3,1,3)
plot(Data3((ii),:))
ylabel('Height (mm)')
title(['Data 3, Index # ',num2str((ii))])
xlabel(' Points ')
Results(ii,:) = {('Normal')}
end
end

채택된 답변

Wookie
Wookie 2022년 1월 22일
I could not get the code working the way I wanted it to work so I made the following adjustments: the function has a ii=ii+1, so I avoid running the main function inside of the for loop. This helped as the waitforkey was not allowing for the uibutton to untoggle. The second thing is I created a global variable Results that kept count of all the times a certain button was pressed. There's probably better ways to do this but this is how I did it.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by