Problem with "uigetfile" command in a compiled executable

1 Ansicht (letzte 30 Tage)
Daniel Kosareo
Daniel Kosareo am 1 Mai 2015
Kommentiert: Libish Jacob am 18 Jan. 2022
I am using “uigetfile” command in a GUI script to browse the files I would like to import. The command, and the program, works in a Matlab environment but not when the code is compiled to an executable. As an executable, the program allows the user to browse the file but no file gets selected (I have an output windows showing the path and file names which remain blank after the browsed file has been selected). I am using “importdata” command to import the files, which works in a Matlab environment. Do you have a solution or workaround to this problem? I have found several online but none of them worked thus far.
  2 Kommentare
Abhiram Bhanuprakash
Abhiram Bhanuprakash am 8 Mai 2015
Hi Daniel,
Can you mention the release of MATLAB (R20xxx) which you are using, and if possible share a sample GUI so that I can try to reproduce the issue on my system?
Abhiram.
Libish Jacob
Libish Jacob am 18 Jan. 2022
I had the same problem, I was using the mcc command directly to create an exe.
To fix this, I created a project file and used evalc('!deploytool -package projectfilename.prj'); to create the exe. And it worked.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Roger
Roger am 8 Mai 2015
[filename, pathname, filterindex] = uigetfile( ...
{ '*.mat','MAT-files (*.mat)'; ...
'*.slx;*.mdl','Models (*.slx, *.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file', ...
'MultiSelect', 'on');
set(handles.text1,'string',pathname);
%assume showing its path in a textbox ,and its tag is text1

Dasharath Gulvady
Dasharath Gulvady am 11 Mai 2015
I'm assuming that you are using "filename" output of "uigetfile" to load a MAT file as follows:
filename = uigetfile
load(filename);
Note that in this case the file has to be in the current directory to get loaded. Instead specify the absolute path as follows:
[filename, pathname] = uigetfile
load([pathname filename])

Kategorien

Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by