QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 6142|回复: 11
打印 上一主题 下一主题

MATLAB-GUI编程案例

[复制链接]
字体大小: 正常 放大
flystar 实名认证       

14

主题

4

听众

539

积分

升级  79.67%

该用户从未签到

新人进步奖

群组flystar

跳转到指定楼层
1#
发表于 2009-1-16 01:08 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
function varargout = test_gui_1(varargin)
% TEST_GUI_1 M-file for test_gui_1.fig
%      TEST_GUI_1, by itself, creates a new TEST_GUI_1 or raises the existing
%      singleton*.
%
%      H = TEST_GUI_1 returns the handle to a new TEST_GUI_1 or the handle to
%      the existing singleton*.
%
%      TEST_GUI_1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TEST_GUI_1.M with the given input arguments.
%
%      TEST_GUI_1('Property','Value',...) creates a new TEST_GUI_1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before test_gui_1_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to test_gui_1_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 test_gui_1

% Last Modified by GUIDE v2.5 09-Jan-2009 11:21:14

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

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

% Update handles structure
guidata(hObject, handles);

%fly
handles.data=0;
guidata(hObject, handles);
%fly

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


% --- Outputs from this function are returned to the command line.
function varargout = test_gui_1_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 selection change in popupmenu_zeta.
function popupmenu_zeta_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_zeta (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%fly
val=get(hObject,'value');
switch val
    case 1
        handles.data=0;
    case 2
        handles.data=0.3;
    case 3
        handles.data=0.5;
    case 4
        handles.data=0.707;
end
guidata(hObject,handles);
%fly

% Hints: contents = get(hObject,'String') returns popupmenu_zeta contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_zeta


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

%fly
x=0:0.1:20;
zeta=handles.data;
y=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
plot(x,y,'r');
axis([0,20,0,2]);
%fly

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

%fly
x=0:0.1:20;
zeta=handles.data;
y=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
plot(x,y,'b');
axis([0,20,0,2]);
%fly


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

%fly
%plot(3,0.7,'r*');
pushbutton_clear_Callback(hObject, eventdata, handles);
a=0.1;
for i=1:5
    a=a+0.3;
    text(2,a,'fly is the best','color','red','fontsize',24,'fontname','courier');
end
axis([0,20,0,2]);
%fly


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

%fly
plot(10,1,'w');
axis([0,20,0,2]);
%fly


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

%fly
x=0:0.1:20;
zeta=handles.data;
for i=1:12
    y=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
    if i-3*fix(i/3)==1
        plot(x+i-2*fix(i/2),y,'b');pause(0.05);axis([0,20,0,2]);
    elseif i-3*fix(i/3)==2
        plot(x+i-2*fix(i/2),y,'r');pause(0.05);axis([0,20,0,2]);
    else
        pushbutton_fly_Callback(hObject, eventdata, handles);pause(0.05);
    end
end
%fly
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
raosu        

11

主题

3

听众

1338

积分

  • TA的每日心情
    慵懒
    2013-5-8 19:57
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    新人进步奖 元老勋章

    群组数学建模

    群组中国矿业大学数学建模协会

    群组数学趣味、游戏、IQ等

    群组南京邮电大学数模协会

    群组我行我数

    回复

    使用道具 举报

    3

    主题

    4

    听众

    86

    积分

    升级  85.26%

    该用户从未签到

    回复

    使用道具 举报

    gtyoyo        

    16

    主题

    3

    听众

    270

    积分

    升级  85%

  • TA的每日心情
    无聊
    2013-4-21 00:18
  • 签到天数: 4 天

    [LV.2]偶尔看看I

    回复

    使用道具 举报

    1

    主题

    1

    听众

    12

    积分

    升级  7.37%

    该用户从未签到

    自我介绍
    骏马秋风冀北,杏花春雨江南!
    回复

    使用道具 举报

    gssrb 实名认证       

    2

    主题

    3

    听众

    199

    积分

    升级  49.5%

  • TA的每日心情
    开心
    2011-10-25 17:38
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    自我介绍
    我期待在数学建模这个舞台上秀出自信,秀出精彩。
    回复

    使用道具 举报

    wajm_011 实名认证       

    3

    主题

    6

    听众

    1163

    积分

    升级  16.3%

  • TA的每日心情
    郁闷
    2012-2-14 03:19
  • 签到天数: 13 天

    [LV.3]偶尔看看II

    自我介绍
    建模,加油加油!!!

    群组数学建摸协会

    群组哈尔滨工业大学建模团

    群组东北三省联盟

    群组Matlab讨论组

    群组数学建模保研联盟

    回复

    使用道具 举报

    三斤 实名认证       

    12

    主题

    5

    听众

    635

    积分

    升级  8.75%

  • TA的每日心情
    奋斗
    2014-7-16 11:15
  • 签到天数: 48 天

    [LV.5]常住居民I

    自我介绍
    就是一四肢发达的人

    新人进步奖

    群组东北三省联盟

    回复

    使用道具 举报

    杨帆 实名认证       

    4

    主题

    4

    听众

    626

    积分

    升级  6.5%

  • TA的每日心情
    奋斗
    2012-12-4 13:38
  • 签到天数: 314 天

    [LV.8]以坛为家I

    新人进步奖 最具活力勋章 发帖功臣

    群组数学趣味、游戏、IQ等

    群组数学建模

    群组我们一定会赢

    回复

    使用道具 举报

    1

    主题

    7

    听众

    224

    积分

    升级  62%

  • TA的每日心情
    开心
    2014-6-12 22:00
  • 签到天数: 59 天

    [LV.5]常住居民I

    自我介绍
    热爱数学,希望在明年参加数学建模竞赛。本人比较诚实,希望大家多多帮助。
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2025-11-10 09:39 , Processed in 1.057259 second(s), 104 queries .

    回顶部