Use string to define path for uigetfile
Show older comments
I am trying to use a string to define the path for uigetfile in matlab GUI. But I can't get it to work. The uigetfile does not use the my string as path. What am I doing wrong?
Here the code I am trying.
pwd={'C:\Users\xxx\Documents\DTU\SAXS\'};
[filename, dirname] = uigetfile(fullfile(pwd,'folder1','*.txt'),'select file')
Accepted Answer
More Answers (1)
Arthur Vidal
on 11 Mar 2018
Edited: Walter Roberson
on 11 Mar 2018
Hi JB, the following code worked well for me. Try it and let me know if work for you.
pwd='C:\Users\xxx\Documents\DTU\SAXS\';
[filename, dirname] = uigetfile('C:\Users\xxx\Documents\DTU\SAXS\*.txt','select file')
Make sure that the string are not cell variables and also that the path your are sending exist.
5 Comments
JB
on 11 Mar 2018
Walter Roberson
on 11 Mar 2018
pwd = 'C:\Users\xxx\Documents\DTU\SAXS\';
[filename, dirname] = uigetfile( fullfile(pwd,'*.txt'), 'select file')
Jan
on 11 Mar 2018
Do not use "pwd" as name of a variable, because it is a built-in function. Such "shadowing" causes unexpected behavior frequently.
Walter Roberson
on 11 Mar 2018
The code I suggested works with Mac.
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!