How to program a push button which will display the graphs signal filter
조회 수: 4 (최근 30일)
이전 댓글 표시
HELLO!
I have small GUI, which will show me 4 graphs from the text file data measured by the phone's accelerometer.
I created the code for a simple moving average filter which is displayed in graphs for individual axes (acceleration in the axis X,Y,Z + speed).
However, these filters are always displayed in the graphs, but I would like to program a pushbutton to show and disappear these filters for individual graphs. Could someone please advise me how to do this?
I'm new to programming and can't figure this out, THANKS!!
Here is my code that permanently display the filter on the x-axis acceleration graph:
% signal smoothing - a moving average filter
samplesPerSec=100;
coeff=ones(1,samplesPerSec)/samplesPerSec;
avgx=filter(coeff,1,x);
fDelay = (length(coeff)-1)/57.7;
tdx=t-fDelay/86;
L2=line(tdx,avgx, 'color', 'blue', 'linewidth',2, 'parent', ax1);
L=[L1 L2]; % handle
ax1=gca;
댓글 수: 0
답변 (1개)
Bora Eryilmaz
2022년 12월 16일
편집: Bora Eryilmaz
2022년 12월 16일
You can set the Visible property of the line object handles to 'off' to hide them. Set them off in your button callback.
x = (1:10)';
y = rand(10,1);
h = line(x,y);
c = uicontrol;
c.String = 'Hide';
c.Callback = @(s,e)hide(h);
function hide(h)
h.Visible = 'off';
end
댓글 수: 2
Bora Eryilmaz
2022년 12월 17일
편집: Bora Eryilmaz
2022년 12월 17일
For each line that you want to turn on/off, store their handles in a variable, similar to what you do in your code:
subplot(211)
L1 = line(1:10,rand(1,10));
subplot(212)
L2 = line(1:10,rand(1,10));
L=[L1 L2]; % handle
Then you can turn off a given line at index k using the code:
k = 2;
L(k).Visible = 'off';
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!