【游戏】基于matlab GUI抽签【含Matlab源码 598期】
2021/6/25 14:56:58
本文主要是介绍【游戏】基于matlab GUI抽签【含Matlab源码 598期】,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、简介
基于matlab GUI抽签
二、源代码
function varargout = example(varargin) % EXAMPLE M-file for example.fig % EXAMPLE, by itself, creates a new EXAMPLE or raises the existing % singleton*. % % H = EXAMPLE returns the handle to a new EXAMPLE or the handle to % the existing singleton*. % % EXAMPLE('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in EXAMPLE.M with the given input arguments. % % EXAMPLE('Property','Value',...) creates a new EXAMPLE or raises % the existing singleton*. Starting from the left, property value pairs are % applied to the GUI before example_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to example_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 example % Last Modified by GUIDE v2.5 14-Dec-2011 23:10:20 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @example_OpeningFcn, ... 'gui_OutputFcn', @example_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 example is made visible. function example_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 example (see VARARGIN) % Choose default command line output for example handles.output = hObject; % Update handles structure guidata(hObject, handles); initialize_gui(hObject, handles, false); % UIWAIT makes example wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = example_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 during object creation, after setting all properties. function density_CreateFcn(hObject, eventdata, handles) % hObject handle to density (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 function density_Callback(hObject, eventdata, handles) % hObject handle to density (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of density as text % str2double(get(hObject,'String')) returns contents of density as a double density = str2double(get(hObject, 'String')); if isnan(density) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end % Save the new density value handles.metricdata.density = density; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function volume_CreateFcn(hObject, eventdata, handles) % hObject handle to volume (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 function volume_Callback(hObject, eventdata, handles) % hObject handle to volume (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of volume as text % str2double(get(hObject,'String')) returns contents of volume as a double volume = str2double(get(hObject, 'String')); if isnan(volume) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end % Save the new volume value handles.metricdata.volume = volume; guidata(hObject,handles) % --- Executes on button press in calculate. function calculate_Callback(hObject, eventdata, handles) % hObject handle to calculate (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % mass = handles.metricdata.density * handles.metricdata.volume; [names]=textread('1.txt','%s'); for j=1:30 mass=names(floor((.2*75*rand(1)+.8*75*rand(1)))); set(handles.mass, 'String', mass); pause(0.1); end % --- 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) [names]=textread('1.txt','%s'); mass=names(floor((.2*75*rand(1)+.8*75*rand(1)))); set(handles.mass, 'String', mass); % --- Executes on button press in reset. function reset_Callback(hObject, eventdata, handles) % hObject handle to reset (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [names]=textread('1.txt','%s'); for j=1:30 mass=names(floor((.2*75*rand(1)+.8*75*rand(1)))); set(handles.mass, 'String', mass); pause(0.1); end mass='01'; set(handles.mass, 'String', mass); % initialize_gui(gcbf, handles, true); % --- Executes when selected object changed in unitgroup. % % function unitgroup_SelectionChangeFcn(hObject, eventdata, handles) % % % hObject handle to the selected object in unitgroup % % % eventdata reserved - to be defined in a future version of MATLAB % % % handles structure with handles and user data (see GUIDATA) % % % % if (hObject == handles.english) % % set(handles.text4, 'String', ''); % % set(handles.text5, 'String', ''); % % set(handles.text6, 'String', ''); % % else % % set(handles.text4, 'String', ''); % % set(handles.text5, 'String', ''); % % set(handles.text6, 'String', ''); % % mass='队长'; % % end % -------------------------------------------------------------------- function initialize_gui(fig_handle, handles, isreset) % If the metricdata field is present and the reset flag is false, it means % we are we are just re-initializing a GUI by calling it from the cmd line % while it is up. So, bail out as we dont want to reset the data. if isfield(handles, 'metricdata') && ~isreset return; end
三、运行结果
四、备注
版本:2014a
完整代码或代写加1564658423
这篇关于【游戏】基于matlab GUI抽签【含Matlab源码 598期】的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南