声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1344|回复: 4

[综合讨论] 编译成exe后程序一闪即逝

[复制链接]
发表于 2007-4-22 10:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我刚开始学gui编程,第一个程序编译成.exe后,运行的时候先出现错误提示如下:

然后就是程序界面一闪即逝。
请问这时什么引起的?
怎么修改?
谢谢!
源程序如下:
源程序如下:
function varargout = signal(varargin)
% SIGNAL M-file for signal.fig
%      SIGNAL, by itself, creates a new SIGNAL or raises the existing
%      singleton*.
%
%      H = SIGNAL returns the handle to a new SIGNAL or the handle to
%      the existing singleton*.
%
%      SIGNAL('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SIGNAL.M with the given input arguments.
%
%      SIGNAL('Property','Value',...) creates a new SIGNAL or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before signal_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to signal_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 test_data to modify the response to help signal

% Last Modified by GUIDE v2.5 25-Mar-2007 17:31:17

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @signal_OpeningFcn, ...
                   'gui_OutputFcn',  @signal_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 signal is made visible.
function signal_OpeningFcn(hObject, eventdata, handles, varargin)
%%%%%%WAITFORCALLBACKS(1)
% 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 signal (see VARARGIN)

% Choose default command line output for signal
%handles.output = hObject;
%handles.SIGNALGenerator=[];

% Update handles structure
%guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = signal_OutputFcn(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% 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;
WAITFORCALLBACKS(1);


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

Signal=PressKeyDown3(handles,'3');
   handles.SIGNALGenerator=Signal;
   
   % Update handles structure
   guidata(hObject, handles);

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

%THE NEXT PART IS NOT THE PROGRAM  BUILD AUTOMATICALLY
   Signal=PressKeyDown1(handles,'1');
   handles.SIGNALGenerator=Signal;
   
   % Update handles structure
   guidata(hObject, handles);
%%   set(handles.test_data,'string','1')
   

% --- Executes on button press in key2.
function key2_Callback(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% hObject    handle to key2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
   Signal=PressKeyDown2(handles,'2');
   handles.SIGNALGenerator=Signal;
   
   % Update handles structure
   guidata(hObject, handles);
   
   %set(handles.test_data,'string','0')

% --- Executes on mouse press over figure background.
function figure1_ButtonDownFcn(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over key1.
function key1_ButtonDownFcn(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% hObject    handle to key1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes during object creation, after setting all properties.
function test_data_CreateFcn(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% hObject    handle to test_data (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function test_data_Callback(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% hObject    handle to test_data (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 test_data as test_data
%        str2double(get(hObject,'String')) returns contents of test_data as a double
Signal=OpeningFcn(handles,'test_data')
handles.SIGNALGenerator=Signal;
% Update handles structure
  guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function key3_CreateFcn(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% hObject    handle to key3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called


% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
    set(hObject,'BackgroundColor',[.9 .9 .9]);
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
%%%%%%WAITFORCALLBACKS(1)
% hObject    handle to slider1 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider




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

Signal=PressKeyDown4(handles,'4');
   handles.SIGNALGenerator=Signal;
   
   % Update handles structure
   guidata(hObject, handles);
   
   set(handles.test_data,'string','')

[ 本帖最后由 angle3839 于 2007-4-22 10:59 编辑 ]
error.JPG
error.JPG
回复
分享到:

使用道具 举报

发表于 2007-4-22 11:50 | 显示全部楼层
原帖由 angle3839 于 2007-4-22 10:56 发表
我刚开始学gui编程,第一个程序编译成.exe后,运行的时候先出现错误提示如下:

然后就是程序界面一闪即逝。
请问这时什么引起的?
怎么修改?
谢谢!
源程序如下:
源程序如下:
function varargout = ...



1. 请给出你使用的matlab版本
2. 请给出你如何编译成exe的
3. 问题的解答可以搜索版面
 楼主| 发表于 2007-4-22 13:13 | 显示全部楼层
原帖由 eight 于 2007-4-22 11:50 发表



1. 请给出你使用的matlab版本
2. 请给出你如何编译成exe的
3. 问题的解答可以搜索版面

我用的是matlab2006版本的,用的命令是:
mcc -m signal.m
signal.m就是要编译的文件。根目录下边有对应的signal.fig和相应的signal.m里边要调用的函数.m文件。
发表于 2007-4-22 13:47 | 显示全部楼层
原帖由 angle3839 于 2007-4-22 13:13 发表

我用的是matlab2006版本的,用的命令是:
mcc -m signal.m
signal.m就是要编译的文件。根目录下边有对应的signal.fig和相应的signal.m里边要调用的函数.m文件。



请搜索:“m文件编译成 exe” ,标题搜索方式
 楼主| 发表于 2007-4-22 16:20 | 显示全部楼层

回复 #4 eight 的帖子

谢谢
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-5 17:25 , Processed in 0.087295 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表