필터 지우기
필터 지우기

Switch and Case using radio buttons

조회 수: 12 (최근 30일)
Darya Zheleznyakova
Darya Zheleznyakova 2021년 11월 3일
편집: Chris 2021년 11월 3일
Hello! I`m kinda new to radiobuttons and actually matlab, haha.
Problem is: it doesn`t work when I press any of radiobuttons. However, if I write "otherwise" and smth after this - this part works.
Here is the first part of code
hGroup4=uibuttongroup('Units','pixels','Position',[x4,y4,w4,h4]);
rb1=uicontrol(hGroup4,'Style','Radio','String','Periodogram','Position',[5,30,90,20],'Tag','b1');
rb2=uicontrol(hGroup4,'Style','Radio','String','Welch method','Position',[5,10,90,20],'Tag','b2');
set(hGroup4,'SelectedObject',[]);
set(hGroup4,'SelectionChangeFcn',@amadelya1);
and the amadelya1 function
function amadelya1(h,Sel)
%unimportant part
switch get(Sel.NewValue,'Tag')
case b1
window=hamming(length(RR4Hz));
[Pxx,f]=periodogram(RR0,window,nfft,Fs);
plot(f(1:Nf),Pxx(1:Nf));
case b2
Nw=500;
noverlap=100;
window=hamming(Nw);
[Pxx,f]=pwelch(RR0,window,noverlap,nfft,Fs);
plot(f(1:Nf),Pxx(1:Nf));
%otherwise
%anyting here and it works no matter wich button I press
Sorry for messy explanation and my english

채택된 답변

Chris
Chris 2021년 11월 3일
편집: Chris 2021년 11월 3일
The tag is a string (technically a char vector). Include the quotes.
case 'b1'
and
case 'b2'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by