file path issue in matlab

11 views (last 30 days)
ali hassan
ali hassan on 27 Jan 2022
Commented: ali hassan on 28 Jan 2022
i have made a GUI and i am using:
to select the file but if the file is not present in MATLAB path, the GUI does not load that file. But if the file is in the MATLAB path,only then it works.
kindly tell me a solution by using which it does not give path error when i load any file using my GUI.
ali hassan
ali hassan on 27 Jan 2022
Unable to find or open '111..txt'. Check the path and filename or file permissions.

Sign in to comment.

Accepted Answer

DGM on 27 Jan 2022
uigetfile() doesn't do anything but return a filename. It doesn't matter where the file is or whether it's on the ML path. It just returns text.
If you aren't getting the full path information for the selected file, or are otherwise not using it whenever you try to read said file, then that's where your problem is.
[filename pathname] = uigetfile('*.png','select an image file')
A = imread(fullfile(pathname,filename));

More Answers (0)


Community Treasure Hunt

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

Start Hunting!