matlabmatlab-app-designer

Matlab how to get file with path only


I am trying to get file with path only without any ui.

Now i am using

[file, path] = uigetfile('*.*');

What i want to do is simple get that file without ui. something like

[file] = getfile(path)

Is there any way how to get that file but same format too as from uigetfile.


Solution

  • Either you know where your file is and/or use dir and its out.folder argument, which contains the full path, or, when your file is in your Present Working Directory, use pwd

    my_folder = '/path/to/folder/';
    files = dir(my_folder)  % Grab all files
    fullpath = [files(ii).folder files(ii).name];  % Generate full path
    
    % Or, if the file is in the PWD
    files = dir(my_folder)  % Grab all files
    fullpath = [pwd files(ii).name];  % Generate full path