# MATLAB Basics video: UIGETFILE for selecting a file in a script, function or GUI4

Posted by Doug Hull,

This is one in a series of videos covering MATLAB basics. It is meant for the new MATLAB user.

This video covers how to use UIGETFILE to make it easier to select a file from a script, function or GUI.

Other videos have been gathered here:
http://blogs.mathworks.com/pick/category/video/

Other MATLAB Basics posts have been gathered here:
http://blogs.mathworks.com/pick/category/matlab-basics/

### Note

Eli replied on : 1 of 4

Say I use uigetfile to get a filename that is in a path not currently part of the matlab path. When I execute the next line of code (load(fileName)), the file will not be loaded since it is not in the current path. How can I go about adding the path (automatically/ without additional user input)?

Cheers,
Eli

Bob replied on : 2 of 4

Eli, does this help?

  [f,p] = uigetfile;


Cheers
Bob

Andreas Kaipanos replied on : 3 of 4

i’m having a problem when using uigetfile in a gui i developed…i have created a pushbutton and in it i have writen:
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data5=importdata(uigetfile(‘*’));
dd=length(data5(:,1));

and it just doesn’t work

Doug replied on : 4 of 4

@Andreas,

What file are you selecting?

If you uigetfile the name of the file directly does it work? What is the error message?