Matlab - Interfaz grafica

   
Vista:

Interfaz grafica

Publicado por Jorge Rodriguez jrodriguezm12@ucentral.edu.co (15 intervenciones) el 15/02/2013 17:50:33
Buen día,

Requiero crear una interfaz de usuario en Matlab. El objetivo es que el usuario ingrese 7 valores numéricos (usando el elemento edit text ) y escogiendo un una opción (de dos) con el elemento Pop up menu. Luego ejecutando el Push Button se active todo el programa. La duda que tengo es la siguiente:

En el pop up menu presento dos opciones YES, NO. Al programa que activo con el Push Button debo llevar la opción que eligió el usuario en el pop up menu, para ejecutar lo sigue:

%Si el usuario eligió Yes debe hacer lo siguiente:

g=r; g1=r1; g2=r2; g3=r3;
R=r/10; R1=r1/10; R3=r3/10;

%Si eligió NO debe continuar con el programa. Aclaro que las variables r, r1, r2 y r3 previamente están creadas.
Adjunto parte del programa con el fin de lograr respuesta.

Gracias.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = Inyeccion(varargin)

function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
PIN=str2double(get(handles.edit1,'String'));
if (isempty(PIN))
set(hObject,'String','0')
end
guidata(hObject,handles);
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
PMN=str2double(get(handles.edit2,'String'));
if (isempty(PMN))
set(hObject,'String','0')
end
guidata(hObject,handles);
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
TIN=str2double(get(handles.edit3,'String'));
if (isempty(TIN))
set(hObject,'String','0')
end
guidata(hObject,handles);
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
TMN=str2double(get(handles.edit4,'String'));
if (isempty(TMN))
set(hObject,'String','0')
end
guidata(hObject,handles);
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end



function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
TMPN=str2double(get(handles.edit5,'String'));
if (isempty(TMPN))
set(hObject,'String','0')
end
guidata(hObject,handles);
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
TEN=str2double(get(handles.edit6,'String'));
if (isempty(TEN))
set(hObject,'String','0')
end
guidata(hObject,handles);
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end



function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
VMN=str2double(get(handles.edit7,'String'));
if (isempty(VMN))
set(hObject,'String','0')
end
guidata(hObject,handles);
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
RT=get(handles.popupmenu2,'Value');

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
vid = videoinput('winvideo', 1, 'I420_2592x1944');
vid.LoggingMode='memory';
FocusMode= 'auto';
src = getselectedsource(vid);
vid.TriggerFrameDelay = 80;
vid.FramesPerTrigger = 1;
vid.ReturnedColorspace = 'grayscale';
triggerconfig(vid, 'manual');
start(vid);
trigger(vid);
m = getdata(vid);
I=medfilt2(m);
level=graythresh(I);
binary=im2bw(I,level);
ww=strel('disk',3);
binary1=imclose(binary,ww);
imshow(binary1);
mat=bwlabel(binary1,8);
max(max(mat));
r=bwarea(binary1);

stats=regionprops(binary1,'Perimeter');
r1=stats(1).Perimeter;

stats=regionprops(binary,'EulerNumber');
r2=stats(1).EulerNumber;

stats=regionprops(binary1,'Perimeter');
r3=stats(1).Perimeter;

%%%%%%%%%%%Aqui debe llegar la opcion que elige el usuario en el pop up menu
if strcmp (reply,'y')
g=r; g1=r1; g2=r2; g3=r3;
R=r/10; R1=r1/10; R3=r3/10;
elseif strcmp (reply,'n')

PI=handles.edit1;
[BB,CC]=parametrosPI(PI);

PM=handles.edit2;
[BB1,CC1]=parametrosPM(PM);

TI=handles.edit3;
[BB2,CC2]=parametrosTI(TI);

TM=handles.edit4;
[BB3,CC3]=parametrosTM(TM);

TMP=handles.edit5;
[BB4,CC4]=parametrosTMP(TMP);

TE=handles.edit6;
[BB5,CC5]=parametrosTE(TE);

VM=handles.edit7;
[BB6,CC6]=parametrosVM(VM);

if (r<g)
disp Piezaincompleta
switch logical(true)
case (g-R<= r & r<=g)
v=[0 0 1 0 0 0 0];
save var.mat
[P_I]=Presion_de_inyeccion(BB,v);
set(handles.text1,'String',P_I);
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