I would like to use UIGETFILE function in order to search for any file from any path of my computer.
3 次查看(过去 30 天)
显示 更早的评论
Hello everyone.
I am new to MatLab, and I would like to know how can I make the program be able to look for any file from any folder of my computer not just the MATLAB folder containing the program.
Currently I am using UIETFILE function and it works if the file is in the MATLAB folder, but if I write the following in the code:
[Archivo, Direccion]=uigetfile({'*.xlsx','Data Files (.xlsx)','*.*','All Files (*.*)'});
I get the following error:
Error using readmatrix (line 158)
Unable to find or open 'Curva_Produccion_Parque.xlsx'. Check the path and filename or file permissions.
Thanks for the help.
0 个评论
采纳的回答
Walter Roberson
2021-10-29
[Archivo, Direccion]=uigetfile({'*.xlsx','Data Files (.xlsx)','*.*','All Files (*.*)'});
if ~ischar(Archivo)
return; %user cancel
end
fullname = fullfile(Direction, Archivo);
data = readmatrix(fullname);
5 个评论
Stephen23
2021-11-4
编辑:Stephen23
2021-11-4
"gives the correct answer for the fullname (Name+path) description as you can see:"
The error message clearly shows you have combined the filename and the filepath in the wrong order:
'Curva_Produccion_Parque.xlsx/-/Users/davidborga/... INICIAL/'
%^^^^^^^^^^^^^^^^^^^^^^^^^^^^ filename
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ filepath
All OS's in common use have the filename at the RHS end of the path (just as Walter Roberson showed you).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!