How can I use fullfile with cell arrays
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
William
am 6 Mai 2013
Kommentiert: Jan Siegmund
am 5 Jul. 2020
[filename, pathname]=uigetfile('MultiSelect','on','*.dat')
f = fullfile(pathname,filename)
filename =
Columns 1 through 5
[1x60 char] [1x60 char] [1x60 char] [1x60 char] [1x60 char]
Columns 6 through 10
[1x60 char] [1x60 char] [1x60 char] [1x60 char] [1x60 char]
Columns 11 through 12
[1x60 char] [1x60 char]
pathname =
C:\Documents and Settings\
??? Undefined function or method 'eq' for input arguments of type 'cell'.
Error in ==> fullfile at 37 if (f(end)==fs) && (part(1)==fs),
Error in ==> load at 3 f = fullfile(pathname,filename)
I'm trying to get the pathname and filename of a set of dat files from a single directory, and want to use fullfile to connect the names together. But I get the above error. Thank you in advance.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 6 Mai 2013
f = cellfun(@(S) fullfile(pathname, S), filename, 'Uniform', 0);
2 Kommentare
John Ettikkalayil
am 22 Mai 2013
Bearbeitet: John Ettikkalayil
am 22 Mai 2013
Thanks Walter! This is what I was looking for in order to display full file paths of multiple files users selected.
f = cellfun(@(S) fullfile(pathname, S), filename, 'Uniform', 0);
disp('User Multi-Selected: ')
disp(f(:))
Weitere Antworten (1)
Jan
am 6 Mai 2013
if pathname(end) == filesep
f = strct({pathname}, filename);
else
f = strct({pathname}, {filesep}, filename);
end
2 Kommentare
Siehe auch
Kategorien
Mehr zu File Name Construction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!