How to use a "list box", check box and plot all together in a GUI?

10 次查看(过去 30 天)
I would like to use a list box command, check box command and a plot command all together in a GUI in Matlab. My sketch is on the attachment.
Is there any one who can help with this?
Thanks in advance :))))
Ercan

回答(3 个)

Image Analyst
Image Analyst 2016-12-15
Description
This GUI will help the novice user get up to speed very quickly on using GUI-based applications. Everything is laid out in a very simple Step 1, Step 2, Step 3, etc. layout. It is a very good starting point for a typical image analysis application. This application uses GUIDE to do the user interface design, and has most of the basic controls such as buttons, listboxes, checkboxes, radio buttons, scrollbars, etc. It allows the user to select a folder of images, select one or more images and display them, to select a series of options, and to individually or batch process one or more images. The user can .........
You don't need to use image processing to use it though - it's very general. You can use whatever kind of data files you want and process them however you want. This app just takes care of the boilerplate plumbing of the GUI and you can customize it from there.

ercan duzgun
ercan duzgun 2016-12-20
What I am trying to do with coding is this:
function denemem
figure ('MenuBar', 'None',...
'Name','SANTEZ Test Sonuçları',...
'NumberTitle', 'Off',...
'Position', [100,100,1200,600])
uicontrol('Style', 'Checkbox',...
'String','Solenoid A',...
'Position', [10,500,100,20],...
'Callback', @Pressed_Solenoid_A);
uicontrol('Style', 'Checkbox',...
'String','Solenoid B',...
'Position', [10,480,100,20],...
'Callback', @Pressed_Solenoid_B);
uicontrol('Style', 'Checkbox',...
'String','Solenoid C',...
'Position', [10,460,100,20],...
'Callback', @Pressed_Solenoid_C);
checkbox1=uicontrol('Style', 'Checkbox',...
'String','Solenoid D',...
'Position', [10,440,100,20],...
'Callback', @Pressed_Solenoid_D);
function Pressed_Solenoid_A (h,eventdata)
disp('A')
checkbox_Solenoid_A = get(h, 'Value');
disp(checkbox_Solenoid_A)
end
function Pressed_Solenoid_B (h,eventdata)
disp('B')
checkbox_Solenoid_B = get(h, 'Value');
disp(checkbox_Solenoid_B)
end
function Pressed_Solenoid_C (h,eventdata)
disp('C')
checkbox_Solenoid_C = get(h, 'Value');
disp(checkbox_Solenoid_C)
end function Pressed_Solenoid_D (h,eventdata)
disp('D')
checkbox_Solenoid_D = get(h, 'Value');
disp(checkbox_Solenoid_D)
end
A=[1,2,3,4,5];
B=[2,3,4,5,6];
C=[3,4,5,6,7];
D=[4,5,6,7,8];
if checkbox_Solenoid_A==1;
figure
plot(A)
hold on;
elseif checkbox_Solenoid_B==1;
plot(B);
hold on;
elseif checkbox_Solenoid_C==1;
plot(C);
hold on;
elseif checkbox_Solenoid_D==1;
plot(A);
else
end
end
However, I can not make it. (the m file is on the attachment) The programme gives an error of
"Undefined function or variable "checkbox_Solenoid_A".
Error in denemem (line 57)
if checkbox_Solenoid_A==1;"
Is there anyone who gives any advice for me?
Thanks in advance

Image Analyst
Image Analyst 2016-12-20
You forgot to assign a few of the controls to handle variables in your code. You only did that for checkbox1 which handles Solenoid D. You need to do that:
checkbox_Solenoid_A = uicontrol('Style', 'Checkbox',...
'String','Solenoid A',...
'Position', [10,500,100,20],...
'Callback', @Pressed_Solenoid_A);
Then to get/check the value do this:
if checkbox_Solenoid_A.Value
% It's checked.
else
% It's not checked.
end

类别

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