function varargout = mayquetvai(varargin) % MAYQUETVAI MATLAB code for mayquetvai.
fig % MAYQUETVAI, by itself, creates a new MAYQUETVAI or raises the existing % singleton*. % % H = MAYQUETVAI returns the handle to a new MAYQUETVAI or the handle to % the existing singleton*. % % MAYQUETVAI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MAYQUETVAI.M with the given input arguments. % % MAYQUETVAI('Property','Value',...) creates a new MAYQUETVAI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before mayquetvai_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to mayquetvai_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help mayquetvai % Last Modified by GUIDE v2.5 10-Oct-2012 05:29:43 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @mayquetvai_OpeningFcn, ... 'gui_OutputFcn', @mayquetvai_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT
% --- Executes just before mayquetvai is made visible. function mayquetvai_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to mayquetvai (see VARARGIN) % Choose default command line output for mayquetvai handles.output = hObject;
% Update handles structure guidata(hObject, handles); axis(handles.axes1,'off'); axis(handles.axes2,'off'); set(handles.text1,'string','Design by Hong Ngc Hai _ C4-5.P307_HBKHN'); global vid i duongdan tamx tamy xvat yvat xvatfull yvatfull zvatfull cam ; vid=0; i=0;duongdan=0;tamx=[];tamy=[];xvat=1;yvat=1;xvatfull=[];yvatfull=[];zvatfull=[];cam=0;
% UIWAIT makes mayquetvai wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = mayquetvai_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
% --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global xyzvat path=cd; [FileName,PathName] = uigetfile({'*.txt';'*.xls'},'Hay lua chon File du lieu dang TEXT hoac EXCEL !!!'); cd(PathName); xyzvat=dlmread(FileName); cd(path); set(handles.text1,'string','D Liu -c Nhp');
% --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global xyzvat axes(handles.axes2); cla(handles.axes1); cla(handles.axes2); Tri = nhom_cac_dinh_mesh(xyzvat); trimesh(Tri,xyzvat(:,1),xyzvat(:,2),xyzvat(:,3),'FaceColor', 'none','EdgeColor','blue'); axis equal; axis on; set(handles.text1,'string','Hon Tt M Phng');
% --- 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) global vid duongdan path i cam i=0; imaqhwinfo; vid=0; duongdan=0; if cam==0 msgbox('Hay Chon CAMERA','ERROR CAMERA','error'); else vid=videoinput('winvideo',cam,'YUY2_640x480'); bat_camera_trong_axes(vid,handles.axes1); ve_tam_ngam_muc_tieu(320,240); if duongdan==0 [path,duongdan]=tao_thu_muc_luu_anh(); end cd(path); end
% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s vid i j duongdan xvatfull yvatfull zvatfull xvat yvat path bamnut thongso tamx tamy bankinh tam_bankinh; xvat=0; yvat=0; %Tien hanh do dat////////////////////////////////////////////// if vid==0 gui_haybatcamera; else if bamnut==1 nguong=thongso{1}(1)/256; p=thongso{2}(1); q=thongso{3}(1); else nguong=150/256; p=10; q=10; end end for j=1:q yvat=0; a=mod(j,2); for i=1:p if a == 1 fwrite(s,17);% cho truc y quay theo time chieu thuan end if a == 0 fwrite(s,18);% cho truc y quay theo time chieu nghich end
pause(1); rgb = getsnapshot(vid); rgb1=ycbcr2rgb(rgb); bw=rgb2nhiphan(rgb1,nguong); luu_anh(i,rgb,bw,duongdan); giatri=kiem_tra_co_vet_hay_khong(bw); if giatri==1 [xc,yc]=xu_ly_anh(rgb,bw); tamx=cat(1,tamx,xc) tamy=cat(1,tamy,yc) zvat = ham_truyen(xc,yc,100,50,4) xvatfull=cat(1,xvatfull,xvat); yvatfull=cat(1,yvatfull,yvat); zvatfull=cat(1,zvatfull,zvat); axes(handles.axes2); cla(handles.axes2); plot3(xvatfull,yvatfull,zvatfull); axis equal; %fprintf(s,'2');pause(0.7); yvat=yvat+0.5; set(handles.text1,'string','ang thu d liuCh t'); else set(handles.text1,'string','ERRORVui lng restart v lm li t u'); end end fwrite(s,19);% cho truc x quay 1 time pause(1); duongdan=tao_thu_muc_2(path); % for k=1:p % fprintf(s,'3');pause(1); %end % fprintf(s,'4');pause(0.7); xvat=xvat+0.5; end xyzvat = [xvatfull yvatfull zvatfull]; tam_bankinh=[tamx tamy bankinh]; %dlmwrite('toadovat.txt', xyzvat, 'delimiter', '\t', 'precision', 6); %dlmwrite('toadovat.xls', xyzvat, 'delimiter', '\t', 'precision', 6); dlmwrite('tam_bankinh.xls', tam_bankinh, 'delimiter', '\t', 'precision', 6); set(handles.text1,'string','Hon tt thu d liu'); cd(path);
% --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in togglebutton3. function togglebutton3_Callback(hObject, eventdata, handles) % hObject handle to togglebutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton3 global s conect if conect==1 dongco3= get(hObject,'Value'); if dongco3 == get(hObject,'Max') fwrite(s,9); elseif dongco3 == get(hObject,'Min') fwrite(s,10); end else msgbox('Please Conect Motor','ERROR','error') set(handles.togglebutton3,'Value',0); end
% --- Executes on button press in togglebutton2. function togglebutton2_Callback(hObject, eventdata, handles) % hObject handle to togglebutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of togglebutton2 global s conect if conect==1 dongco2= get(hObject,'Value'); if dongco2 == get(hObject,'Max') fwrite(s,7); elseif dongco2 == get(hObject,'Min') fwrite(s,8); end else msgbox('Please Conect Motor','ERROR','error') set(handles.togglebutton2,'Value',0); end
% --- Executes on button press in togglebutton2. function togglebutton1_Callback(hObject, eventdata, handles) % hObject handle to togglebutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of togglebutton2 global s conect if conect==1 dongco1= get(hObject,'Value'); if dongco1 == get(hObject,'Max') fwrite(s,5); elseif dongco1 == get(hObject,'Min') fwrite(s,6);
end else msgbox('Please Conect Motor','ERROR','error') set(handles.togglebutton1,'Value',0); end % -------------------------------------------------------------------function Conect_ClickedCallback(hObject, eventdata, handles) % hObject handle to Conect (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s conect COM s = serial(COM); s.Baudrate=9600; s.InputBufferSize=8000; s.Terminator=''; conect=1; stop=0; baoloi(s); set(handles.text2,'string','Conecting...');
% -------------------------------------------------------------------function Disconect_ClickedCallback(hObject, eventdata, handles) % hObject handle to Disconect (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s conect fclose(s); clear s; conect=0; set(handles.text2,'string','Disconect...');
% -------------------------------------------------------------------function Restart_ClickedCallback(hObject, eventdata, handles) % hObject handle to Restart (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s conect stop luachon =gui_reset('Title','RESET Chuong Trinh'); switch lower(luachon) case 'khong' % do nothing case 'co' %Xoa het du lieu vua thu va RESET cac bien. cla(handles.axes1,'reset'); %clears the axes cla(handles.axes2,'reset'); %clears the axes clear global; axis(handles.axes1,'off'); axis(handles.axes2,'off'); clear s; conect=0;
stop=0; set(handles.text2,'string','Restart'); set(handles.togglebutton1,'Value',0); set(handles.togglebutton2,'Value',0); set(handles.togglebutton3,'Value',0); set(handles.radiobutton4,'Value',1); set(handles.text1,'string','RESTART Xong...Lm Li T u i...:))'); fclose(s); end
% -------------------------------------------------------------------function com_Callback(hObject, eventdata, handles) % hObject handle to com (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------function com1_Callback(hObject, eventdata, handles) % hObject handle to com1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global COM COM='COM1'; set(handles.text2,'string','COM1');
% -------------------------------------------------------------------function com2_Callback(hObject, eventdata, handles) % hObject handle to com2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global COM COM='COM2'; set(handles.text2,'string','COM2'); % -------------------------------------------------------------------function com3_Callback(hObject, eventdata, handles) % hObject handle to com3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global COM COM='COM3'; set(handles.text2,'string','COM3'); % -------------------------------------------------------------------function com4_Callback(hObject, eventdata, handles) % hObject handle to com4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global COM COM='COM4'; set(handles.text2,'string','COM4'); % -------------------------------------------------------------------function com5_Callback(hObject, eventdata, handles) % hObject handle to com5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global COM COM='COM5'; set(handles.text2,'string','COM5'); % -------------------------------------------------------------------function com6_Callback(hObject, eventdata, handles) % hObject handle to com6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global COM COM='COM6'; set(handles.text2,'string','COM6'); % -------------------------------------------------------------------function com7_Callback(hObject, eventdata, handles) % hObject handle to com7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global COM COM='COM7'; set(handles.text2,'string','COM7');
function baoloi(obj) errorOccurred = false; jobject = igetfield(obj, 'jobject'); warnState = warning('backtrace', 'off'); % Call fopen on each java object. Keep looping even % if one of the objects could not be opened. for i=1:length(jobject), try fopen(jobject(i)); catch aException errorOccurred = true; msg = aException.message; end end % Report error if one occurred. if errorOccurred if length(jobject) == 1 errordlg('Please Check COM','Error'); else warning('MATLAB:serial:fopen:invalid','An object in OBJ could not be opened or was already open.'); end end warning(warnState);
% --- Executes when selected object is changed in uipanel6. function uipanel6_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in uipanel6 % eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) global s conect if conect==1 switch get(eventdata.NewValue,'Tag') case 'radiobutton4' fwrite(s,1); %chon toc do min case 'radiobutton2' fwrite(s,2); %chon toc do 1 case 'radiobutton3' fwrite(s,3); %chon toc do 2 case 'radiobutton1' fwrite(s,4); %chon toc do max end else msgbox('Please Conect Motor','ERROR','error') set(handles.radiobutton4,'Value',1); end
% --- Executes on button press in togglebutton8. function togglebutton8_Callback(hObject, eventdata, handles) % hObject handle to togglebutton8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of togglebutton8 global s conect if conect==1 chieu1= get(hObject,'Value'); if chieu1== get(hObject,'Max') fwrite(s,11); set(handles.togglebutton8,'string','Ra'); elseif chieu1 == get(hObject,'Min') fwrite(s,12); set(handles.togglebutton8,'string','Vo'); end else msgbox('Please Conect Motor','ERROR','error') set(handles.togglebutton8,'Value',0); end
% --- Executes on button press in togglebutton9. function togglebutton9_Callback(hObject, eventdata, handles) % hObject handle to togglebutton9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of togglebutton9 global s conect if conect==1 chieu2= get(hObject,'Value'); if chieu2== get(hObject,'Max')
fwrite(s,13); set(handles.togglebutton9,'string','Tri'); elseif chieu2 == get(hObject,'Min') fwrite(s,14); set(handles.togglebutton9,'string','Phi'); end else msgbox('Please Conect Motor','ERROR','error') set(handles.togglebutton9,'Value',0); end
% --- Executes on button press in togglebutton10. function togglebutton10_Callback(hObject, eventdata, handles) % hObject handle to togglebutton10 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of togglebutton10 global s conect if conect==1 chieu3= get(hObject,'Value'); if chieu3== get(hObject,'Max') fwrite(s,15); set(handles.togglebutton10,'string','Xung'); elseif chieu3 == get(hObject,'Min') fwrite(s,16); set(handles.togglebutton10,'string','Ln'); end else msgbox('Please Conect Motor','ERROR','error') set(handles.togglebutton10,'Value',0); end
% -------------------------------------------------------------------function camera_Callback(hObject, eventdata, handles) % hObject handle to camera (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------function cam1_Callback(hObject, eventdata, handles) % hObject handle to cam1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global cam cam=1; % -------------------------------------------------------------------function cam2_Callback(hObject, eventdata, handles) % hObject handle to cam2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global cam
cam=2;
% -------------------------------------------------------------------function cam3_Callback(hObject, eventdata, handles) % hObject handle to cam3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global cam cam=3; % -------------------------------------------------------------------function cam4_Callback(hObject, eventdata, handles) % hObject handle to cam4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global cam cam=4; % -------------------------------------------------------------------function cam5_Callback(hObject, eventdata, handles) % hObject handle to cam5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global cam cam=5;
% -------------------------------------------------------------------function thongso_Callback(hObject, eventdata, handles) % hObject handle to thongso (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global thongso bamnut; prompt={'Nguong anh sang:';'Buoc ngang:';'Buoc doc:'}; name='Cau hinh thong so he thong'; formats(1) = struct('type','edit','format','float'); formats(2) = struct('type','edit','format','float'); formats(3) = struct('type','edit','format','float'); defaultanswer={150,10,10}; [thongso,canceled] = nhapthongsohethong(prompt,name,formats,defaultanswer); bamnut=1; set(handles.text1,'string','Nhp Thng S Thnh Cng');
% -------------------------------------------------------------------function exit_ClickedCallback(hObject, eventdata, handles) % hObject handle to exit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.text1,'string','Design by Hong Ngc Hai _ C4-5.P307_HBKHN'); global s; luachon =gui_exit('Title','Thoat Khoi Chuong Trinh'); switch lower(luachon) case 'khong'
% do nothing case 'co' close(handles.figure1); fclose(s); clear all; end
% --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) rotate3d off; pan off; zoom on; % --- Executes on button press in pushbutton8. function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) pan off; zoom off; rotate3d on;
% --- Executes on button press in pushbutton9. function pushbutton9_Callback(hObject, eventdata, handles) % hObject handle to pushbutton9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) rotate3d off; zoom off; pan on;
% --- Executes on button press in pushbutton10. function pushbutton10_Callback(hObject, eventdata, handles) % hObject handle to pushbutton10 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) datacursormode on;
% --- Executes on button press in pushbutton16. function pushbutton16_Callback(hObject, eventdata, handles) % hObject handle to pushbutton16 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s conect stop luachon =gui_reset('Title','RESET Chuong Trinh'); switch lower(luachon) case 'khong'
% do nothing case 'co' %Xoa het du lieu vua thu va RESET cac bien. cla(handles.axes1,'reset'); %clears the axes cla(handles.axes2,'reset'); %clears the axes clear global; axis(handles.axes1,'off'); axis(handles.axes2,'off'); clear s; conect=0; stop=0; set(handles.text2,'string','Restart'); set(handles.togglebutton1,'Value',0); set(handles.togglebutton2,'Value',0); set(handles.togglebutton3,'Value',0); set(handles.radiobutton4,'Value',1); set(handles.text1,'string','RESTART Xong...Lm Li T u i...:))'); fclose(s); end
% --- Executes on button press in pushbutton17. function pushbutton17_Callback(hObject, eventdata, handles) % hObject handle to pushbutton17 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.text1,'string','Design by Hong Ngc Hai _ C4-5.P307_HBKHN'); global s; luachon =gui_exit('Title','Thoat Khoi Chuong Trinh'); switch lower(luachon) case 'khong' % do nothing case 'co' close(handles.figure1); fclose(s); clear all; 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) % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu2 global cam val = get(hObject,'Value'); switch val case 1 cam=1; case 2 cam=2;
case 3 cam=3; case 4 cam=4; case 5 cam=5; case 6 cam=6; end
% --- 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 pushbutton11. function pushbutton11_Callback(hObject, eventdata, handles) % hObject handle to pushbutton11 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s conect COM s = serial(COM); s.Baudrate=9600; s.InputBufferSize=8000; s.Terminator=''; conect=1; stop=0; baoloi(s); set(handles.text2,'string','Conecting...'); % --- Executes on button press in pushbutton12. function pushbutton12_Callback(hObject, eventdata, handles) % hObject handle to pushbutton12 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s conect fclose(s); clear s; conect=0; set(handles.text2,'string','Disconect...'); % --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1 global COM val = get(hObject,'Value'); switch val; case 1 COM='COM1'; set(handles.text2,'string','COM1'); case 2 COM='COM2'; set(handles.text2,'string','COM2'); case 3 COM='COM3'; set(handles.text2,'string','COM3'); case 4 COM='COM4'; set(handles.text2,'string','COM4'); case 5 COM='COM5'; set(handles.text2,'string','COM5'); case 6 COM='COM6'; set(handles.text2,'string','COM6'); end
% --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (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 pushbutton18. function pushbutton18_Callback(hObject, eventdata, handles) % hObject handle to pushbutton18 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global thongso bamnut; prompt={'Nguong anh sang:';'Buoc ngang:';'Buoc doc:'}; name='Cau hinh thong so he thong'; formats(1) = struct('type','edit','format','float'); formats(2) = struct('type','edit','format','float'); formats(3) = struct('type','edit','format','float'); defaultanswer={150,10,10}; [thongso,canceled] = nhapthongsohethong(prompt,name,formats,defaultanswer); bamnut=1;
set(handles.text1,'string','Nhp Thng S Thnh Cng');