gusucode.com > matlab界面设计的一些资料笔记,可以做为初学者参考用 > GUI制作中文资料/fag5/xiangweiqi.m

    function varargout = xiangweiqi(varargin)
% XIANGWEIQI M-file for xiangweiqi.fig
%      XIANGWEIQI, by itself, creates a new XIANGWEIQI or raises the existing
%      singleton*.
%
%      H = XIANGWEIQI returns the handle to a new XIANGWEIQI or the handle to
%      the existing singleton*.
%
%      XIANGWEIQI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in XIANGWEIQI.M with the given input arguments.
%
%      XIANGWEIQI('Property','Value',...) creates a new XIANGWEIQI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before xiangweiqi_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to xiangweiqi_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 xiangweiqi

% Last Modified by GUIDE v2.5 06-Aug-2007 21:21:40

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @xiangweiqi_OpeningFcn, ...
                   'gui_OutputFcn',  @xiangweiqi_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 xiangweiqi is made visible.
function xiangweiqi_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 xiangweiqi (see VARARGIN)
%express=findobj('tag','radiobuttonjin')

%
model_open(handles)
% Choose default command line output for xiangweiqi
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);


global  jinb jina
assignin('base','jinb',jina)
%jinb = jina
%jinb = evalin('base','jina');

if jinb==0
 set(handles.tanhuang,'Enable','off')
end
% UIWAIT makes xiangweiqi wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = xiangweiqi_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;

% ------------------------------------------------------------
% Ensure that the Simulink model is open
% ------------------------------------------------------------
function model_open(handles)
% Make sure the diagram is still open
  if  isempty(find_system('Name','PIDkongzhixiangying')),
    open_system('PIDkongzhixiangying'); 
        end
%endfunction model_open

function zhuanjiao_Callback(hObject, eventdata, handles)
% hObject    handle to zhuanjiao (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global dd
% Hints: get(hObject,'String') returns contents of zhuanjiao as text
%        str2double(get(hObject,'String')) returns contents of zhuanjiao as a double
% Hints: get(hObject,'String') returns contents of shudu as text
%        str2double(get(hObject,'String')) returns contents of shudu as a double
  model_open(handles)

  % Get the new value for the Kf Gain
  NewStrVal = get(hObject,'String');
  NewVal = str2num(NewStrVal);

  % Check that the entered value falls within the allowable range
  if  isempty(NewVal) || (NewVal< 0) || (NewVal>60),
    % Revert to last value, as indicated by KfValueSlider
    set(hObject,'String',dd)
    assignin('base','stroke',str2double(dd));
    
    %'constant value',get(handles.shudu,'String'))
  else
   
      dd= NewStrVal;
      assignin('base','stroke',NewVal);
    
      % Set the Gain parameter of the Kf Gain Block to the new value
  %assignin('base','zhuanshu',NewVal);
  end


% --- Executes during object creation, after setting all properties.
function zhuanjiao_CreateFcn(hObject, eventdata, handles)
% hObject    handle to zhuanjiao (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 xv2_Callback(hObject, eventdata, handles)
% hObject    handle to xv2 (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 xv2 as text
%        str2double(get(hObject,'String')) returns contents of xv2 as a double
  model_open(handles)
  NewStrVal = get(hObject,'String');
  NewVal = str2num(NewStrVal);
  assignin('base','dead_vol_A',NewVal);
    
      % Set the Gain parameter of the Kf Gain Block to the new value
  %assignin('base','zhuanshu',NewVal);
 


% --- Executes during object creation, after setting all properties.
function xv2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xv2 (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 xv3_Callback(hObject, eventdata, handles)
% hObject    handle to xv3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
  model_open(handles)
  NewStrVal = get(hObject,'String');
  NewVal = str2num(NewStrVal);
  assignin('base','dead_vol_B',NewVal);
% Hints: get(hObject,'String') returns contents of xv3 as text
%        str2double(get(hObject,'String')) returns contents of xv3 as a double


% --- Executes during object creation, after setting all properties.
function xv3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xv3 (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 xv4_Callback(hObject, eventdata, handles)
% hObject    handle to xv4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
model_open(handles)
  NewStrVal = get(hObject,'String');
  NewVal = str2num(NewStrVal);
  assignin('base','leak_coeff',NewVal);
% Hints: get(hObject,'String') returns contents of xv4 as text
%        str2double(get(hObject,'String')) returns contents of xv4 as a double


% --- Executes during object creation, after setting all properties.
function xv4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xv4 (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 xv6_Callback(hObject, eventdata, handles)
% hObject    handle to xv6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
  model_open(handles)
  NewStrVal = get(hObject,'String');
  NewVal = str2num(NewStrVal);
  assignin('base','zhighe',NewVal);
% Hints: get(hObject,'String') returns contents of xv6 as text
%        str2double(get(hObject,'String')) returns contents of xv6 as a double


% --- Executes during object creation, after setting all properties.
function xv6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xv6 (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 xvv7_Callback(hObject, eventdata, handles)
% hObject    handle to xvv7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
model_open(handles)
  NewStrVal = get(hObject,'String');
  NewVal = str2num(NewStrVal);
  assignin('base','drad',NewVal);
% Hints: get(hObject,'String') returns contents of xvv7 as text
%        str2double(get(hObject,'String')) returns contents of xvv7 as a double


% --- Executes during object creation, after setting all properties.
function xvv7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xvv7 (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 xv8_Callback(hObject, eventdata, handles)
% hObject    handle to xv8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
model_open(handles)
  NewStrVal = get(hObject,'String');
  NewVal = str2num(NewStrVal);
  assignin('base','zrad',NewVal);
% Hints: get(hObject,'String') returns contents of xv8 as text
%        str2double(get(hObject,'String')) returns contents of xv8 as a double


% --- Executes during object creation, after setting all properties.
function xv8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to xv8 (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 tanhuang_Callback(hObject, eventdata, handles)
% hObject    handle to tanhuang (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%global jinb

% Hints: get(hObject,'String') returns contents of tanhuang as text
%        str2double(get(hObject,'String')) returns contents of tanhuang as a double


% --- Executes during object creation, after setting all properties.
function tanhuang_CreateFcn(hObject, eventdata, handles)
% hObject    handle to tanhuang (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