Compiled version not working because of path

조회 수: 3 (최근 30일)
Douglas Anderson
Douglas Anderson 2020년 1월 25일
댓글: Image Analyst 2020년 1월 26일
Hello,
I have compiled similar programs successfully with earlier versions (e.g. 2017a), but now in 2019b have this issue.
Get this message in testing the software:
ctrlv error.png
Here is the code that may be a problem. I also use the utility uipickfiles() from file exchange. Never use "addpath" itself. How do you find files if not like this?
% Plot the logo
[~,lingo] = dos('set username');
login = lingo(10:end-1);
% Plot the background and the logo: Background on axes2, logo on axes3
dir_name = ['C:\Users\',login,'\Desktop'];
wiggle_file_name = [dir_name,'\wiggles3.jpg'];
if exist(wiggle_file_name,'file')
imshow(wiggle_file_name);
end
logo_file_name = [dir_name,'\ctrl_v_logo.jpg'];
% imshow(logo_file_name); % Overwrites axes2
imshow(logo_file_name,'Parent',handles.axes3);
Any thoughts? This part is just to put a logo on the screen to start the program -- used to work! I'm not sure if the error occurs elsewhere, though.
I advise the user to put the installer on the Desktop as well as these figures.

채택된 답변

Allen
Allen 2020년 1월 25일
If you are certain that the image you are looking for is always going to be on the Desktop and your OS is Win10, you can try the following line of code. This should work for Win8 as well, but am not certain about other OSs. I use this line of code frequently with trying to setup a splahscreen for my apps and executables, and have done so in the latest version of MATLAB.
dir_name = ['C:\Users\',getenv('USERNAME'),'\Desktop\'];
  댓글 수: 2
Douglas Anderson
Douglas Anderson 2020년 1월 25일
Thank you Allen
A question though: I think the error is in my use of the utility "uipickfiles()". I tried packaging a junk program that only calls that utility and prints out the result. It came up with the same error.
Is there a replacement for uipickfiles()? Or how should your solution go into that rather large utility?
Doug
Allen
Allen 2020년 1월 25일
I typically use uigetfile for initiating user file selections. I also like to assign a default starting directory when using uigetfile and its counterpart uiputfile in my GUIs. As I delve further into using this GUI, I generally have a project folder that I save and access pertinent files and it makes sense to update this default directory. The following is a short example of how I might call this function and update it if changed within a GUIDE GUI.
...
[fn,pn] = uigetfile(fullfile(handles.startdir,'*.mat'),'Select Project File','MultiSelect','off');
if ~isnumeric(pn)
handles.startdir = pn;
end
...
% Update handles structure
guidata(hObject,handles);

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2020년 1월 25일
You need to modify your startup.m so that it does not add anything to the search path if isdeployed() is true.
  댓글 수: 4
Walter Roberson
Walter Roberson 2020년 1월 25일
startup.m gets called automatically when MATLAB is started, provided it can find one in the path at the appropriate location.
Because MATLAB assumes that startup.m is setting important local customizations that are going to be needed by the MATLAB code, then MATLAB Compiler automatically looks for startup.m and incorporates it as part of the executable, to be run before the function that you designate as the entry point.
Image Analyst
Image Analyst 2020년 1월 26일
However even if you place the cd() or addpath() command in the "if ~isdeployed" block, it will still warn you -- I know from experience. In that case, just ignore the warning.

댓글을 달려면 로그인하십시오.


Douglas Anderson
Douglas Anderson 2020년 1월 26일
Thank you for all the help!
I actually found out that restoredefaultpath() was needed to clear up the mess!
I've learned a lot more now, though, and thanks to everyone!

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by