Stand alone windows .exe crashes after using deploy tool?
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
Hi there, I have been trying to create a stand alone windows application from my GUI, but everytime I do so it crashes and does not give me any results? Though it works fine if I run the .m file. I have put my code below, if anyone can see any reason why this would be happening it would be a huge help!
(If it's useful, typical values for the edit text boxes would be - 400e-9, 4e-9, 295, 9.6e-4 and 200)
Thanks.
     function varargout = GUI(varargin)
    % GUI MATLAB code for GUI.fig
    %      GUI, by itself, creates a new GUI or raises the existing
    %      singleton*.
    %
    %      H = GUI returns the handle to a new GUI or the handle to
    %      the existing singleton*.
    %
    %      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
    %      function named CALLBACK in GUI.M with the given input arguments.
    %
    %      GUI('Property','Value',...) creates a new GUI or raises the
    %      existing singleton*.  Starting from the left, property value pairs are
    %      applied to the GUI before GUI_OpeningFcn gets called.  An
    %      unrecognized property name or invalid value makes property application
    %      stop.  All inputs are passed to GUI_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 GUI
    % Last Modified by GUIDE v2.5 06-Jul-2012 13:54:29
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @GUI_OpeningFcn, ...
                       'gui_OutputFcn',  @GUI_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 GUI is made visible.
    function GUI_OpeningFcn(hObject, ~, 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 GUI (see VARARGIN)
    % Choose default command line output for GUI
    handles.output = hObject;
    handles.a = 0;
    handles.b = 0;
    handles.T = 0;
    handles.N = 0;
    handles.alpha = 0;
    handles.timer=0;
    handles.steady=0;
    % Update handles structure
    guidata(hObject, handles);
    % UIWAIT makes GUI wait for user response (see UIRESUME)
    % uiwait(handles.figure1);
    % Menus
    filemenu = uimenu('Label','File');
    uimenu(filemenu,'Label','Exit','Callback',@closeRequestFcn);
     function closeRequestFcn(varargin)
            % Close the Figure Window
            closereq;
    % --- Outputs from this function are returned to the command line.
    function varargout = GUI_OutputFcn(~, ~, 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;
    function a_box_Callback(hObject, ~, handles)
    % hObject    handle to a_box (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 a_box as text
    %        str2double(get(hObject,'String')) returns contents of a_box as a double
    handles.a = str2double(get(hObject,'String'));
    guidata(hObject,handles);
    % --- Executes during object creation, after setting all properties.
    function a_box_CreateFcn(hObject, ~, ~)
    % hObject    handle to a_box (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 b_box_Callback(hObject, ~, handles)
    % hObject    handle to b_box (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 b_box as text
    %        str2double(get(hObject,'String')) returns contents of b_box as a double
    handles.b = str2double(get(hObject,'String'));
    guidata(hObject,handles);
    % --- Executes during object creation, after setting all properties.
    function b_box_CreateFcn(hObject, ~, ~)
    % hObject    handle to b_box (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 T_box_Callback(hObject, ~, handles)
    % hObject    handle to T_box (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 T_box as text
    %        str2double(get(hObject,'String')) returns contents of T_box as a double
    handles.T = str2double(get(hObject,'String'));
    guidata(hObject,handles);
    % --- Executes during object creation, after setting all properties.
    function T_box_CreateFcn(hObject, ~, ~)
    % hObject    handle to T_box (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 N_box_Callback(hObject, ~, handles)
    % hObject    handle to N_box (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 N_box as text
    %        str2double(get(hObject,'String')) returns contents of N_box as a double
    handles.visc = str2double(get(hObject,'String'));
    guidata(hObject,handles);
    % --- Executes during object creation, after setting all properties.
    function N_box_CreateFcn(hObject, ~, ~)
    % hObject    handle to N_box (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 alpha_box_Callback(hObject, ~, handles)
    % hObject    handle to alpha_box (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 alpha_box as text
    %        str2double(get(hObject,'String')) returns contents of alpha_box as a double
    handles.G = str2double(get(hObject,'String'));
    guidata(hObject,handles);
    % --- Executes during object creation, after setting all properties.
    function alpha_box_CreateFcn(hObject, ~, ~)
    % hObject    handle to alpha_box (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 during object creation, after setting all properties.
    function axes1_CreateFcn(~, ~, ~)
    % hObject    handle to axes1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    empty - handles not created until after all CreateFcns called
    % Hint: place code in OpeningFcn to populate axes1
    % handles.axes1=hobject;
    % guidata(hObject,handles);
    % --- Executes on button press in execute.
    function execute_Callback(~, ~, handles)
    % hObject    handle to execute (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    tic;
    hp = uipanel('Title','Steady State Value','FontSize',14,...
                 'Position',[.7499999999990 .12 .215 .12]);
    time_pan = uipanel('Title','Calculation Time','FontSize',14,...
                 'Position',[.07 .85 .215 .12]);
    % Parameters
    k_b = 1.3806503e-23;
    r = handles.a/handles.b;
    F_t = sqrt(r^2-1)/(r^(1/3)*log(r+sqrt(r^2-1)));
    F_r = (4*(r^4-1))/((3*r^2)*(((2*(2*r^2-1))/(r^(4/3)*F_t))-2));
    lambda = (4*F_r*pi*handles.visc*handles.a*handles.b^2)/(3*k_b*handles.T);
    global M;
    P_lambda = handles.G*lambda; %Peclet number
    N = 12; %Solution expansion order (N even)
    N_tilde = (N/2+1)^2-1; %Number of non-trivial ODEs
    N_total = 2*(N+1)^2; %Number of A_iqp for i=0,1, p,q=0,1,2,...,N
    N_ind = N_total/2;
    A = ones(N_total,1); %A_inm (or A_iqp)
    for n = 0:N    
        A((N+1)^2+n*(N+1)+1,1) = 0; %A_1n0=0    
    end
    M = zeros(N_total,N_total); %Matrix of coefficients of the A_iqp for the A_dot_iqp. For example, M(1,iqp)=M(1,i(N+1)^2+q(N+1)+p+1)
    a = zeros(N+1,N+1,N+1,N+1); %a(m+1,n+1,p+1,q+1) for m,n,p,q = 0,...,N
    %We calculate the a_mpnq
    for n = 0:2:N
        for m = 0:2:n
            for q = 0:2:N
                for p = 0:2:q
                    if ((m-p==2) && (n-q==2))
                       a(m+1,n+1,p+1,q+1) = (n-2)*factorial(n+m)*(1-eq(m,0))/(4*(2*n+1)*(2*n-1)*factorial(n+m-4));
                    elseif ((m-p==2) && (n-q==0))
                       a(m+1,n+1,p+1,q+1) = 3*factorial(n-m+2)*factorial(n+m)*(1-eq(m,0))/(4*(2*n-1)*(2*n+3)*factorial(n+m-2)*factorial(n-m));
                    elseif ((m-p==2) && (n-q==-2))
                       a(m+1,n+1,p+1,q+1) = -(n+3)*factorial(n-m+4)*(1-eq(m,0))/(4*(2*n+1)*(2*n+3)*factorial(n-m));
                    elseif ((m-p==0) && (n-q==0))
                       a(m+1,n+1,p+1,q+1) = -m/2;
                    elseif ((m-p==-2) && (n-q==2))
                       a(m+1,n+1,p+1,q+1) = -(n-2)*(1+eq(m,0))/(4*(2*n+1)*(2*n-1));
                    elseif ((m-p==-2) && (n-q==0))
                       a(m+1,n+1,p+1,q+1) = -3*(1+eq(m,0))/(4*(2*n-1)*(2*n+3));
                    elseif ((m-p==-2) && (n-q==-2))
                       a(m+1,n+1,p+1,q+1) = (n+3)*(1+eq(m,0))/(4*(2*n+1)*(2*n+3));
                    end 
                end 
            end 
        end
    end
    %After applying the Galerkin method, we obtain a linear system of ODEs.
        for q = 0:2:N
            for p = 0:2:q
                for n = 0:2:N
                    for m = 0:2:n 
                        M(q*(N+1)+p+1,q*(N+1)+p+1) = -q*(q+1)/6; %Coefficient of A_0qp for A_dot_0qp
                        M(q*(N+1)+p+1,(N+1)^2+n*(N+1)+m+1) = -P_lambda*a(m+1,n+1,p+1,q+1); %Coefficients of the A_1nm for A_dot_0qp
                        M((N+1)^2+q*(N+1)+p+1,(N+1)^2+q*(N+1)+p+1) = -q*(q+1)/6; %Coefficient of A_1qp for A_dot_1qp
                        M((N+1)^2+q*(N+1)+p+1,n*(N+1)+m+1) = P_lambda*a(m+1,n+1,p+1,q+1); %Coefficients of the A_0nm for A_dot_1qp                    
                    end                
                end            
            end        
        end
    M = M*diag(A); %Set the coefficients of the A_1n0 to zero to account for A_1n0=0
    M(1,:) = 0; %Set the coefficients for A_dot_000 to zero
    for q=0:2:N    
        M((N+1)^2+q*(N+1)+1,:) = 0; %Set the coefficients for the A_dot_1q0 to zero    
    end
    x0 = zeros(N_total,1); %Initial conditions
    x0(1,1) = 1;     %A_000(t=0)=1 
    dx = @(tau,x)  M*x;
    x = ode45(dx,[0,10],x0); %Solve in the interval tau=[0,10]
    N_steps = size(x.x,2); %Number of time steps in ODE solutions
    syms  the phi cthe
    poly = vpa(zeros(1,N+1));
    for n = 0:N
        poly(n+1) = (1/(2^n*factorial(n)))*diff((cthe^2-1)^n,cthe,n); %generate legendre polynomials
    end
    P = vpa(zeros(N+1,N+1));
    for n = 0:1:N
        for m = 0:1:n
            if m > n
                P(m+1,n+1) = 0;
            else 
                P(m+1,n+1) = ((-1)^m)*((sin(the))^m)*diff((poly(n+1)),cthe,m);  %calculate matrix of associated Legendre polynomials
            end
        end
    end
    P_fin = subs(P,cthe,cos(the));
    P_fina = eval(P_fin);  %these three lines substitute cos(the) back in for cthe
    A0 = x.y(1:N_ind,:);  %generte matrix of A_0 amplitudes 
    A1_inp = N_total+1;
    A1 = x.y(N_ind+1:N_total,:); %generte matrix of A_1 amplitudes
    MM = zeros(N_ind,1);
    MM(1) = 0;
    for n = 1:N_ind-1
        MM(n+1) = MM(n)+1;
        if MM(n)==12
           MM(n+1) = 0;       %generate m values for psi calculation
        end
    end
    psi = vpa(zeros(N_ind, N_steps));
    P_final = reshape(P_fina,N_ind,1);
    for t = 1:1:N_steps
        psi(:,t) = (A0(:,t).*P_final.*cos(MM.*phi))+(A1(:,t).*P_final.*sin(MM.*phi));
    end
    final_psi = sum(psi(1:N_ind,:)).*(1/(4*pi));
    test = final_psi.*sin(the);
    fun_for_S = ((sin(the)^2)*(cos(phi)^2)).*test;  %function to be integrated
    sincos = double(int(int((fun_for_S),the,0,(pi)),phi,0,(2*pi))); %integrate with respect to theta and phi
    S = (0.5)*((3.*sincos)-1);  %calculate orientation parameter at each time point
    time = x.x .* lambda;
    leg = num2str(handles.G);
    leg_string = strcat(leg, ' s^{-1}');
    plot(time,S, 'DisplayName', leg_string);
    xlabel('Time / s','FontSize',14)
    ylabel('Orientation / S', 'FontSize',14)
    title('\it{Calculation of Orientation Parameter}','FontSize',18)
    xlim([0 time(N_steps)])
    hold all
    legend('-DynamicLegend', 'Location', 'East')
    display_ss = num2str(S(N_steps));
    display_time_1 = num2str(toc);
    display_time = strcat(display_time_1, ' seconds');
    hList = uicontrol('Parent',hp,'Style','text','Position',[90 4 70 30]);
    set(hList,'String',display_ss, 'FontSize',13);  % Displays steady state value
    hList = uicontrol('Parent',time_pan,'Style','text','Position',[45 4 150 30]);
    set(hList,'String',display_time, 'FontSize',13);  % Displays time taken for calculation in seconds
    clear all
댓글 수: 0
답변 (1개)
  Kaustubha Govind
    
      
 2012년 7월 10일
        Could you try running your executable from a command window (as opposed to simply double-clicking on it)? Alternatively, you can compile your application as a "Console Application" instead of "Windows Standalone". Using either technique, the executable will report any errors in the system command window. Debugging those errors will help you figure out a solution.
댓글 수: 4
  Andrew Groth
 2013년 3월 4일
				I tried most of these suggestions. I hadn't thought to check dependencies. Everything looked ok there, though. I didn't think most of the suggestions applied because the complied app worked ok when I ran it from the windows command line. It was just when I double-clicked it. Should I open a ticket with tech support? Thanks!
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




