필터 지우기
필터 지우기

drop down list and function

조회 수: 9 (최근 30일)
Indri Ristika Utami
Indri Ristika Utami 2023년 6월 30일
편집: Ram Sreekar 2023년 7월 12일
so i made a simple guide with one of the features is the drop down list, but i find the diffilcuties by connecting the input menu from the drop down list to other function. this is my codes, so the purpose is user can choose one of this filters.
%---------------------------- F I L T E R ---------------------------------
%----------------------------- D E L T A ----------------------------------
Fs = 100;
order = 12;
f_low = 1;
f_high = 4;
[Delta] = Bandpass_Butter(f_low,f_high,Fs,order)
data_Delta = filter(Delta, Filtered_Data);
%----------------------------- T H E T A ----------------------------------
order = 12;
f_low = 4;
f_high = 8;
[Theta] = Bandpass_Butter(f_low,f_high,Fs,order)
data_Theta = filter(Theta, Filtered_Data);
%----------------------------- A L P H A ----------------------------------
order = 12;
f_low = 8;
f_high = 14;
[Alpha] = Bandpass_Butter(f_low,f_high,Fs,order)
data_Alpha = filter(Alpha, Filtered_Data);
%------------------------------ B E T A -----------------------------------
order = 12;
f_low = 14;
f_high = 30;
[Beta] = Bandpass_Butter(f_low,f_high,Fs,order)
data_Beta = filter(Beta, Filtered_Data);
%----------------------------- G A M M A ----------------------------------
order = 12;
f_low = 30;
f_high = 40;
[Gamma] = Bandpass_Butter(f_low,f_high,Fs,order)
data_Gamma = filter(Gamma, Filtered_Data);
  댓글 수: 1
Image Analyst
Image Analyst 2023년 6월 30일
If you have any more questions, then attach your .m and .fig files with the paperclip icon after you read this:

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

답변 (1개)

Ram Sreekar
Ram Sreekar 2023년 7월 12일
편집: Ram Sreekar 2023년 7월 12일
Hi Indri Ristika Utami ,
I understand that you are trying to execute the function ‘Bandpass_Butter’ and ‘filter’ with different values for “f_low”, “f_high” based on the selection from dropdown.
This can be done by using the ‘switch’ statement and assigning different values to “f_low” and “f_high” based on the selection in the dropdown. You can refer to the sample code given below.
% Create a figure to hold the GUI elements
figure('Name', 'Filter Selection');
% Create a drop-down menu
filterMenu = uicontrol('Style', 'popupmenu', 'String', {'Delta', 'Theta', 'Alpha', 'Beta', 'Gamma'},...
'Position', [200 200 100 100], 'Callback', @filterSelectionCallback);
% Define the callback function for the drop-down menu
function filterSelectionCallback(source, ~)
% Get the selected filter from the drop-down menu
selectedFilter = source.Value;
% Define the filter parameters based on the selected option
switch selectedFilter
case 1 % Delta
f_low = 1;
f_high = 4;
case 2 % Theta
f_low = 4;
f_high = 8;
case 3 % Alpha
f_low = 8;
f_high = 14;
case 4 % Beta
f_low = 14;
f_high = 30;
case 5 % Gamma
f_low = 30;
f_high = 40;
end
% Apply the selected filter
Fs = 100;
order = 12;
[filter] = Bandpass_Butter(f_low, f_high, Fs, order);
filteredData = filter(filter, Filtered_Data);
% Perform any further processing or display as needed
end
Hope this helps you resolve your query.

카테고리

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