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

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





% Last Modified by GUIDE v2.5 08-Aug-2007 10:30:36

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @vct0805_OpeningFcn, ...
                   'gui_OutputFcn',  @vct0805_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 vct0805 is made visible.
function vct0805_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)

image_date=imread('vvvct.JPG');
image(image_date)
set(gca,'xtick',[],'ytick',[]);
%fig = handles.F14ControllerEditor;
% varargin   command line arguments to vct0805 (see VARARGIN)
global  jinb jina
 NewStrVal = get(handles.radiobuttonjin,'Value');
%h = guihandles( gcbf )
 %handles.jinb=NewStrVal;
 %guidate(h,handles);
 %NewVal = str2num(NewStrVal);
 assignin('base','jina',NewStrVal);
%窗口最大化开始
%Screen=get(0,'ScreenSize')
%set(gcf,'OuterPosition',Screen);
%窗口大化完

    
model_open(handles)

% Choose default command line output for vct0805
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes vct0805 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = vct0805_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'); 
    %open_system('PIDkongzhixiangying/vane')
    %set_param('f14/Controller/Gain','Position',[275 14 340 56])
    %figure(handles.F14ControllerEditor)
    % Put  values of Kf and Ki from the GUI into the Block dialogs
    %set_param('PIDkongzhixiangying/Constant1',...
    %'Constant value',get(handles.shudu,'String'))
    %set_param('PIDkongzhixiangying/vane/Proportional plus integral compensator',...
             % 'Numerator',get(handles.wendu,'String'))
  end
%endfunction model_open

function shudu_Callback(hObject, eventdata, handles)
% hObject    handle to shudu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global shudu;
% 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>6000),
    % Revert to last value, as indicated by KfValueSlider
    set(hObject,'String',shudu)
    assignin('base','zhuanshu',str2double(shudu));
        %set_param('PIDkongzhixiangying','Constant1',shudu)
      % set_param('PIDkongzhixiangying/Constant1',...
    %'constant value',get(handles.shudu,'String'))
  else
%assignin('base','oldval',NewStrVal);
      shudu = NewStrVal;
      %get(hObject,'String');
    % 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 shudu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to shudu (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 wendu_Callback(hObject, eventdata, handles)
% hObject    handle to wendu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 global oldval
NewStrVal = get(hObject,'String');
  NewVal = str2double(NewStrVal);

  % Check that the entered value falls within the allowable range
  if  isempty(NewVal) || (NewVal< 0) || (NewVal>150),
    % Revert to last value, as indicated by KfValueSlider
    set(handles.wendu,'String',oldval)
    assignin('base','oilwen',str2double(oldval));
    %set_param('f14/Controller/Proportional plus integral compensator',...
             % 'Numerator',oldval)
   else
    oldval = NewStrVal ;    
    assignin('base','oilwen',NewVal);
    % Set the Gain parameter of the Kf Gain Block to the new value
   % set_param('f14/Controller/Proportional plus integral compensator',...
              %'Numerator',NewStrVal)
  end
% Hints: get(hObject,'String') returns contents of wendu as text
%        str2double(get(hObject,'String')) returns contents of wendu as a double


% --- Executes during object creation, after setting all properties.
function wendu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to wendu (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 youya_Callback(hObject, eventdata, handles)
% hObject    handle to youya (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
NewStrVal = get(hObject,'String');
  NewVal = str2double(NewStrVal);
  assignin('base','oilya',NewVal);
 % set_param('f14/Controller','Ka',NewStrVal)
% Hints: get(hObject,'String') returns contents of youya as text
%        str2double(get(hObject,'String')) returns contents of youya as a double


% --- Executes during object creation, after setting all properties.
function youya_CreateFcn(hObject, eventdata, handles)
% hObject    handle to youya (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 button press in VCT.
function VCT_Callback(hObject, eventdata, handles)
% hObject    handle to VCT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
open('xiangweiqi.fig');
 %figure('Name','xiangweiqi');


% --- Executes on button press in valve.
function valve_Callback(hObject, eventdata, handles)
% hObject    handle to valve (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
open('ywyafacanshu.fig');

% --- Executes on button press in pid.
function pid_Callback(hObject, eventdata, handles)
% hObject    handle to pid (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
open('PIDcanshu.fig');


% --- Executes on button press in xitong.
function xitong_Callback(hObject, eventdata, handles)
% hObject    handle to xitong (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

open('xitongcanshu.fig');

function phaseinite_Callback(hObject, eventdata, handles)
% hObject    handle to phaseinite (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','inite_phase',NewVal);
% Hints: get(hObject,'String') returns contents of phaseinite as text
%        str2double(get(hObject,'String')) returns contents of phaseinite as a double


% --- Executes during object creation, after setting all properties.
function phaseinite_CreateFcn(hObject, eventdata, handles)
% hObject    handle to phaseinite (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 button press in simulinkkai.
function simulinkkai_Callback(hObject, eventdata, handles)
% hObject    handle to simulinkkai (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% [timeVector,stateVector,outputVector] = sim('PIDkongzhixiangying',[0 0.2]);
  
xiangyinshudu

% --- 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)


% --- 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)


% --- Executes on button press in stop.
function stop_Callback(hObject, eventdata, handles)
% hObject    handle to stop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close_system('Name','PIDkongzhixiangying')


function begine_t_Callback(hObject, eventdata, handles)
% hObject    handle to begine_t (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','begine_opening',NewVal);
% Hints: get(hObject,'String') returns contents of begine_t as text
%        str2double(get(hObject,'String')) returns contents of begine_t as a double


% --- Executes during object creation, after setting all properties.
function begine_t_CreateFcn(hObject, eventdata, handles)
% hObject    handle to begine_t (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 begine_O_Callback(hObject, eventdata, handles)
% hObject    handle to begine_O (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','begine_over',NewVal);
% Hints: get(hObject,'String') returns contents of begine_O as text
%        str2double(get(hObject,'String')) returns contents of begine_O as a double


% --- Executes during object creation, after setting all properties.
function begine_O_CreateFcn(hObject, eventdata, handles)
% hObject    handle to begine_O (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 button press in radiobuttonjin.
function radiobuttonjin_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonjin (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%jinb=get(hObject,'Value')
% Hint: get(hObject,'Value') returns toggle state of radiobuttonjin


% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton5 (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 radiobutton5


% --- Executes on button press in radiobuttonexit.
function radiobuttonexit_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonexit (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 radiobuttonexit


% --- Executes on button press in radiobutton6.
function radiobutton6_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton6 (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 radiobutton6





function edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double


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