Matlab - Problema con popup menu

 
Vista:
sin imagen de perfil

Problema con popup menu

Publicado por Hector (15 intervenciones) el 21/12/2013 21:04:41
Buenas tardes,

Soy bastante novato creando una interfaz gráfica en Matlab y tengo una consulta que supongo será bastante simple para vosotros como expertos en el área. Estoy intentando crear un pequeña gui que haga un calculo simple de un numero el cual se extrae de un menú popu-up y se muestre en un cuadro de texto. He podido mostrar los valores del pop-up en el cuadro de texto "First", pero no así el cálculo (cuadro de texto "Second").

De antemano, muchísimas gracias por vuestra ayuda!

Esto es lo que tengo hasta ahora:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function gui_pop_menu
 
hFig = figure('units','pixels','position',[350 100 100 100],'menubar','none','name','gui_pop_menu',...
              'numbertitle','off','resize','on');
 
hPopup = uicontrol('Parent',hFig,'style','popupmenu','unit','pix','position',[30 60 100 20],...
    'fontsize',16,'fontweight','bold',...
                 'string',{'2';'8';'94';'15'},'value',1,'Callback',@Popup_Callback);
 
hOutput = uicontrol('Parent',hFig,'Units','characters','BackgroundColor',[1 1 1],...
    'FontSize',16,'ForegroundColor',[0 0 0],'Position',[5 0.5 16 2.5],...
    'String','First','value',1,'Style','edit');
 
hOutputb = uicontrol('Parent',hFig,'Units','characters','BackgroundColor',[1 1 1],...
    'FontSize',16,'ForegroundColor',[0 0 0],'Position',[25 0.5 16 2.5],...
    'String','Second','value',1,'Style','edit');
 
function Popup_Callback(hObject, eventdata);
Ax = get(hPopup,'String');
By = get(hPopup,'Value')
Cz = Ax(By,:);
 
set(hOutput,'String',(Cz));
 
Dn = log(Cz);
 
set(hOutputb,'String',(Dx));
 
end
 
end
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIA CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Problema con popup menu

Publicado por JOSE JEREMIA CABALLERO (5917 intervenciones) el 22/12/2013 01:22:18
Cuando hagas tu pregunta, evita usar el termino simple, para evitar susceptibilidades en los usuarios de matlab.

Ninguna pregunta es tonta, ninguna pregunta es fácil, ninguna pregunta es difícil, todo depende del conocimiento que tenga el usuario de Matlab.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function gui_pop_menu
     close all
     hFig = figure(...
     'units','pixels',...
     'position',[400 300 500 300],...
     'menubar','none',...
     'name','gui_pop_menu',...
     'numbertitle','off',...
     'resize','on');
 
     hPopup = uicontrol(...
     'Parent',hFig,...
     'style','popupmenu',...
     'unit','pix',...
     'position',[30 60 100 20],...
     'fontsize',16,...
     'fontweight','bold',...
     'string',{'20';'80';'940';'150'},...  % imprime
     'value',1,...
     'Callback',@Popup_Callback);
 
     hOutput = uicontrol(...
     'Parent',hFig,...
     'Units','characters',...
     'BackgroundColor',[1 1 1],...
     'FontSize',16,...
     'ForegroundColor',[0 0 0],...
     'Position',[5 0.5 16 2.5],...
     'String','First',...%% visualiza
     'value',1,...
     'Style','edit');
 
     hOutputb = uicontrol(...
     'Parent',hFig,...
     'Units','characters',...
     'BackgroundColor',[1 1 1],...
     'FontSize',16,...
     'ForegroundColor',[0 0 0],...
     'Position',[25 0.5 16 2.5],...
     'String','Second',...  %% visualiza
     'value',1,...
     'Style','edit');
 
     function Popup_Callback(hObject, eventdata);
     Ax = get(hPopup,'String');
     By = get(hPopup,'Value');
     Cz = Ax{By};
     set(hOutput,'String',Cz);
     Dn = log10(str2num(Cz));
     set(hOutputb,'String',Dn);
     end
 
 end



Saludos.
JOSE JEREMÍAS CABALLERO
Asesorías en Matlab
programador en matlab
Servicios de programación matlab
[email protected]


http://matlabcaballero.blogspot.com

http://www.lawebdelprogramador.com/foros/Matlab/1371532-FORMA_DE_APRENDER_MATLAB.html
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Problema con popup menu

Publicado por Hector (15 intervenciones) el 22/12/2013 12:40:55
Hola José,

muchísimas gracias por tu ayuda, y también por el consejo, funciona perfectamente.

Saludos y felices fiestas!

Héctor
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar