1、1.仿真图在仿真界面画出仿真图并保存为:zengyisina.m2.画GUI界面3.编写M文件,详细的注释如代码,自己要写的部分很少,大多是系统自动生成的代码。function varargout = zengyi(varargin)% ZENGYI MATLAB code for zengyi.fig% ZENGYI, by itself, creates a new ZENGYI or raises the existing% singleton*.% H = ZENGYI returns the handle to a new ZENGYI or the handle to% the e
2、xisting singleton*.% ZENGYI(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in ZENGYI.M with the given input arguments.% ZENGYI(Property,Value,.) creates a new ZENGYI or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the G
3、UI before zengyi_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to zengyi_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose “GUI allows only one% instance to run (singleton)“.% See also: GUIDE, GUI
4、DATA, GUIHANDLES% Edit the above text to modify the response to help zengyi% Last Modified by GUIDE v2.5 02-Dec-2012 14:20:08% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, .gui_Singleton, gui_Singleton, .gui_OpeningFcn, zengyi_OpeningFcn, .gui_Outp
5、utFcn, zengyi_OutputFcn, .gui_LayoutFcn, , .gui_Callback, );if nargin endif nargoutvarargout1:nargout = gui_mainfcn(gui_State, varargin:);elsegui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before zengyi is made visible.function zengyi_OpeningFcn(hObject
6、, eventdate, 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 zengyi (see VARARGIN)axes(hand
7、les.axes1);X=imread(tuxing.bmp,bmp);image(X)axis off;% Choose default command line output for zengyihandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes zengyi wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are ret
8、urned to the command line.function varargout = zengyi_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 (se
9、e GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;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
10、GUIDATA)% 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)% eve
11、ntdata 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 end% - Executes on button press in pushbutton1.function pushbutton1_Cal
12、lback(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)open zengyisina;%调用系统的open函数打开文件set_param(zengyisina/Gain,Gain,get(handles.edit1,string);/设置仿真系统中的
13、参数。% - 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)sim(zengyisina);/系统开始仿真figure;/打开一个画图界面。plot(A1(:,1),A1(:,2);plot(handles.axes2,A1(:,1),A1(:,2);%plot(A1(:,1),A1(:,2);4.运行仿真可以通过改变增益的数值,先点击保存参数,后再点击开始仿真,仿真出来的波形显示在上面的窗口中。此做了一个简单的GUI界面,其中包括图片的显示,参数的设置,如何把GUI 界面把仿真中的参数设置和仿真运行及波形的显示联系起来等方法。可以举一反三运用到电力系统仿真GUI界面的制作中。