How does MATLAB know which .mat file to LOAD when there are two files with the same name in two different folders?
이전 댓글 표시
I have added several paths in MATLAB so that I don't have to do it manually every time I start MATLAB. In those paths (or directories), there are multiple files having the same name. Let say I want to load a file, namely 'KTB2007' using load() function without manually go to a specific directory and select it. MATLAB can perform this no problem, but how does MATLAB know which KTB2007 file to load? In both KTB2007 files, there are several variables having identical names as well? I just want to ensure I don't load the wrong file.
댓글 수: 3
KSSV
2018년 4월 9일
Try this:
[filepath,name,ext] = fileparts(filename) ;
It will give you path of the file, from this you may know the path of the file.
Walter Roberson
2018년 4월 9일
That will not work for files loaded by way of the MATLAB path.
KSSV
2018년 4월 9일
Okay...then the first path added, from there it takes the file?
답변 (1개)
Walter Roberson
2018년 4월 9일
0 개 추천
If you want to see where MATLAB finds a specific file, you can use which() with the file name.
As for which one MATLAB will find: it has a search path; https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html
카테고리
도움말 센터 및 File Exchange에서 Standard File Formats에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!