Why is a figure-object not visible in my deployed Matlab standalone .exe window?
12 次查看(过去 30 天)
显示 更早的评论
I have compiled and deployed a .exe standalone to several recipients with success. However, for some of the recipients the figure-object is not visible. How can I solve this problem for the recipients?
5 个评论
Christian Præstegaard Sørensen
2015-9-30
I am using 2015b. In the area with the blue circle I have a plot. Somehow this plot is visible to some recipients and not to others.
Jan
2015-9-30
Does the program run correctly for the other parts? Perhaps it stops before creating the diagram with an error, e.g. due to a missing input file, which exists on some computers but not on others? Perhaps there is any other bug in the code, which let the plot disappear, e.g. a wrong assumption for the screen resolution. Without seeing a relevant part of the code it is impossible to guess the reason.
Christian Præstegaard Sørensen
2015-10-1
编辑:Walter Roberson
2015-10-1
The code is found below. Feel free to look it through.
However, I think it is a graphical problem with Matlabs compiler for R2015b as the GUI is working for some recipients and not for others.
--------------------
---- -- CODE -- ----
--------------------
function varargout = trayportPrices(varargin)
% TRAYPORTPRICES MATLAB code for trayportPrices.fig
% TRAYPORTPRICES, by itself, creates a new TRAYPORTPRICES or raises the existing
% singleton*.
%
% H = TRAYPORTPRICES returns the handle to a new TRAYPORTPRICES or the handle to
% the existing singleton*.
%
% TRAYPORTPRICES('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TRAYPORTPRICES.M with the given input arguments.
%
% TRAYPORTPRICES('Property','Value',...) creates a new TRAYPORTPRICES or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before trayportPrices_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to trayportPrices_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 trayportPrices
% Last Modified by GUIDE v2.5 25-Sep-2015 09:46:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @trayportPrices_OpeningFcn, ...
'gui_OutputFcn', @trayportPrices_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 trayportPrices is made visible.
function trayportPrices_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 trayportPrices (see VARARGIN)
% Set names in popupmenu 1 & 3
p1=fnGetMarketAreas();
set(handles.popupmenu1, 'string', p1);
set(handles.popupmenu3, 'string', p1);
% Set names in popupmenu 2 & 4
p2=fnGetContractNames();
set(handles.popupmenu2, 'string', p2);
set(handles.popupmenu4, 'string', p2);
% Set names in popupmenu 5 & 6
p3=fnGetTradeDates();
set(handles.popupmenu5, 'string', p3);
set(handles.popupmenu6, 'string', p3);
% Initialize handles
set(handles.popupmenu1, 'Value',5)
set(handles.popupmenu2, 'Value',6)
set(handles.popupmenu3, 'Value',3)
set(handles.popupmenu4, 'Value',6)
set(handles.popupmenu5, 'Value',2)
set(handles.popupmenu6, 'Value',1)
set(handles.checkbox1, 'Value',0)
set(handles.checkbox7, 'Value',0)
handles.val1 = get(handles.popupmenu1, 'Value');
handles.val2 = get(handles.popupmenu2, 'Value');
handles.val3 = get(handles.popupmenu3, 'Value');
handles.val4 = get(handles.popupmenu4, 'Value');
handles.val5 = get(handles.popupmenu5, 'Value');
handles.val6 = get(handles.popupmenu6, 'Value');
handles.cb1 = get(handles.checkbox1, 'Value');
handles.cb7 = get(handles.checkbox7, 'Value');
% Set timer function
handles.t = timer('StartDelay', 15, 'Period', 120, 'ExecutionMode', 'fixedRate');
% Choose default command line output for trayportPrices
% handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes trayportPrices wait for user response (see UIRESUME)
uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = trayportPrices_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 popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.val1 = get(hObject, 'Value');
% Error handling for live data
set(handles.checkbox7, 'Value',0)
handles.cb7 = get(handles.checkbox7, 'Value');
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% Save the handles structure.
guidata(hObject,handles)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (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 selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.val2 = get(hObject, 'Value');
% Error handling for live data
set(handles.checkbox7, 'Value',0)
handles.cb7 = get(handles.checkbox7, 'Value');
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% Save the handles structure.
guidata(hObject,handles)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.val3 = get(hObject, 'Value');
% Error handling for live data
set(handles.checkbox7, 'Value',0)
handles.cb7 = get(handles.checkbox7, 'Value');
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% Save the handles structure.
guidata(hObject,handles)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu3
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu3 (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 selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.val4 = get(hObject, 'Value');
% Error handling for live data
set(handles.checkbox7, 'Value',0)
handles.cb7 = get(handles.checkbox7, 'Value');
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% Save the handles structure.
guidata(hObject,handles)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu4 (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 selection change in popupmenu5.
function popupmenu5_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.val5 = get(hObject, 'Value');
% Error handling for live data
set(handles.checkbox7, 'Value',0)
handles.cb7 = get(handles.checkbox7, 'Value');
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% Save the handles structure.
guidata(hObject,handles)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu5 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu5
% --- Executes during object creation, after setting all properties.
function popupmenu5_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu5 (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 selection change in popupmenu6.
function popupmenu6_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.val6 = get(hObject, 'Value');
% Error handling for live data
set(handles.checkbox7, 'Value',0)
handles.cb7 = get(handles.checkbox7, 'Value');
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% Save the handles structure.
guidata(hObject,handles)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu6 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu6
% --- Executes during object creation, after setting all properties.
function popupmenu6_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu6 (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 checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.cb1 = get(hObject, 'Value');
% Error handling for live data
set(handles.checkbox7, 'Value',0)
handles.cb7 = get(handles.checkbox7, 'Value');
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% Save the handles structure.
guidata(hObject,handles)
% Hint: get(hObject,'Value') returns toggle state of checkbox1
% --- Executes on button press in checkbox7.
function checkbox7_Callback(hObject, eventdata, handles)
% hObject handle to checkbox7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.cb7 = get(hObject, 'Value');
% Call live data activating pushbutton 1
handles.t.TimerFcn = @(x,y) pushbutton1_Callback(hObject, eventdata, handles);
% Error handling for live data
if (strcmp(get(handles.t, 'Running'), 'off') && handles.cb7 == 1)
start(handles.t);
else
stop(handles.t);
end
% Hint: get(hObject,'Value') returns toggle state of checkbox7
% Save the handles structure.
guidata(hObject,handles)
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(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)
% Error handling for live data
if (strcmp(get(handles.t, 'Running'), 'on') && handles.cb7 == 0)
stop(handles.t);
end
% h = waitbar(0,'Loading...'); %Waitbar
% set(h, 'Position', [500 500 250 40])
% db call
marketAreas = fnGetMarketAreas();
contractNames = fnGetContractNames();
tradeDates = fnGetTradeDates();
% waitbar(1/10); %Waitbar
% identifying variables for db call
i1_1 = char(marketAreas(handles.val1));
i2_1 = char(contractNames(handles.val2));
i1_2 = char(marketAreas(handles.val3));
i2_2 = char(contractNames(handles.val4));
i3 = char(tradeDates(handles.val5));
i4 = char(tradeDates(handles.val6));
% waitbar(2/10); %Waitbar
% Load data for contract 1
handles.current_data1 = fnGetData(i1_1,i2_1,i3,i4);
% idx = (handles.current_data1(:,1)>now());% Set future values to NaN
% handles.current_data1(idx==1,2) = NaN;
% waitbar(5/10); %Waitbar
% Load data for contract 2
handles.current_data2 = fnGetData(i1_2,i2_2,i3,i4);
% idx = (handles.current_data2(:,1)>now());% Set future values to NaN
% handles.current_data2(idx==1,2) = NaN;
% waitbar(8/10); %Waitbar
% waitbar(7/10);
% Load data for GBPEUR if relevant
if strcmp(i1_1,'NBP')==1
i_gbp = fnGetGBPEUR(i3,i4); % Define NBP in EUR/MWh
handles.current_data1(:,2) = i_gbp(:,2).*handles.current_data1(:,2)/100/29.307*1000;
else
handles.current_data1(:,2) = handles.current_data1(:,2);
end
if strcmp(i1_2,'NBP')==1
i_gbp = fnGetGBPEUR(i3,i4); % Define NBP in EUR/MWh
handles.current_data2(:,2) = i_gbp(:,2).*handles.current_data2(:,2)/100/29.307*1000;
else
handles.current_data2(:,2) = handles.current_data2(:,2);
end
% close(h) %Waitbar
% Ready to plot data
cla(gca);
% Set tick labels
if length(handles.current_data1)>=(120*5)
idHour=hour(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder time
idMin=minute(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder min
tick_index = find((idHour == 9) & idMin == 0);
tick_label = datestr(handles.current_data1(tick_index,1), 'dd-mmm HH:MM');
elseif (length(handles.current_data1)<(120*5) && length(handles.current_data1)>110*2)
idHour=hour(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder time
idMin=minute(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder min
tick_index = find((idHour == 9 | idHour == 13) & idMin == 0);
tick_label = datestr(handles.current_data1(tick_index,1), 'dd-mmm HH:MM');
elseif (length(handles.current_data1)<(110*2) && length(handles.current_data1)>108)
idHour=hour(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder time
idMin=minute(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder min
tick_index = find(idMin == 0);
tick_label = datestr(handles.current_data1(tick_index,1), 'dd. HH:MM');
else
% idHour=hour(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder time
idMin=minute(datetime(handles.current_data1(:,1),'ConvertFrom','datenum')); %Finder min
tick_index = find(idMin == 0 | idMin == 30);
tick_label = datestr(handles.current_data1(tick_index,1), 'HH:MM');
end
% Load current price
% Contract 1
p_now1 = handles.current_data1(:,2);
idx_now1 = min(find((handles.current_data1(:,1)>now())));
p_now1(:)=NaN;
p_now1(idx_now1)=handles.current_data1(idx_now1,2);
% Contract 2
p_now2 = handles.current_data2(:,2);
idx_now2 = min(find((handles.current_data2(:,1)>now())));
p_now2(:)=NaN;
p_now2(idx_now2)=handles.current_data2(idx_now2,2);
% Spread
p_now1_p_now2 = p_now1-p_now2;
% Set background color to white
set(gca,'color','w');
% Plot data
if (handles.cb1 == 0) % Plot of contract 1
data_plot = handles.current_data1(:,2);
plot(data_plot,'b');
hold on
plot(p_now1,'k.', 'markersize', 10);
set(gca, 'XTick', tick_index);
set(gca, 'XTickLabel', tick_label);
set(gca,'FontSize',7)
ylim([min(data_plot)-0.05 max(data_plot)+0.05])
ax = gca;
ax.XTickLabelRotation = 30;
ylabel('EUR/MWh')
grid on
ax.GridLineStyle = '-';
ax.GridColor = 'k';
else % Plot of spread contract
data_plot = handles.current_data1(:,2)-handles.current_data2(:,2);
plot(data_plot,'r');
hold on
plot(p_now1_p_now2,'k.', 'markersize', 10);
set(gca, 'XTick', tick_index);
set(gca, 'XTickLabel', tick_label);
set(gca,'FontSize',7)
ylim([min(data_plot)-0.05 max(data_plot)+0.05])
ax = gca;
ax.XTickLabelRotation = 30;
ylabel('EUR/MWh')
grid on
ax.GridLineStyle = '-';
ax.GridColor = 'k';
end
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.
function pushbutton1_ButtonDownFcn(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)
回答(1 个)
Image Analyst
2015-9-30
It's a known bug. See this discussion: http://www.mathworks.com/matlabcentral/answers/243839-compiled-version-change-it-s-design
4 个评论
Christian Præstegaard Sørensen
2015-10-1
I've tried workaround 2 and workaround 3 but it does not solve the problem. The graphics of the window is changed, but the plot is still not visible for some of the end users.
Also I tried to reinstall the Matlab Runtime for the end users, but the problem is not solved. Maybe there is a bug in Matlab Runtime 9.0 ....?
Christian Præstegaard Sørensen
2015-10-9
Finally I found a solution.
By running the .exe from cmd I got the following:
I found out that the recipients with this error all had the ATI FirePro v2460 installed. Somehow there is a problem with Matlab working together with ATI FirePro.
By including the following command in the openingFunction of my GUI I solved the problem.
set(gcf, 'GraphicsSmoothing','off')
Image Analyst
2015-10-9
Good that you somehow found a solution. I never would have found out that graphics-card-specific problem and workaround.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)