Juraj Jakubov
Juraj Jakubov

Reputation: 261

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.

Upvotes: 0

Views: 170

Answers (2)

Adriaan
Adriaan

Reputation: 18177

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

Upvotes: 1

PedroRodriguez
PedroRodriguez

Reputation: 368

You can get a list of all files with the command dir, the following code will display the names of all files:

files = dir;
files.name

Then, you have to get the file you want.

Upvotes: 0

Related Questions