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.

採用された回答

Walter Roberson
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
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).
David Borrego
David Borrego 2021 年 11 月 4 日
Indeed it was my mistake changing filepath for filename.
Thank you so much for your help (and sorry to Walter whose answer was perfect).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by