フィルターのクリア

case sensitivity issue of "load" function

2 ビュー (過去 30 日間)
Yu Li
Yu Li 2024 年 3 月 30 日
編集済み: John D'Errico 2024 年 3 月 30 日
Hi:
I see in documentation here:
Matlab is case sensitve, however, I noticed that the load function is not case sensitive in some situation. for example, I have a file locate in path: C:/Test/abc.mat, I can read the file by
A=load('C:/Test/abc.mat'),
or
A=load('C:/test/abc.mat')
so my question is, is there anyway to make the load function case sensitivy, i.e. returns empty when I enter A=load('C:/test/abc.mat')
Thanks!
Yu
  1 件のコメント
Stephen23
Stephen23 2024 年 3 月 30 日
"...is there anyway to make the load function case sensitivy..."
No, because the behavior you describe is entirely due to your OS. It has nothing to do with MATLAB.

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

採用された回答

John D'Errico
John D'Errico 2024 年 3 月 30 日
編集済み: John D'Errico 2024 年 3 月 30 日
You cannot change the behavior of existing supplied code. If it works that way, then it does, and there is no way to tell load to be case sensitive on the file name.
Anyway, the thing is, the case sensitivity is probably not a MATLAB issue, but a file system issue. For example, I see that the help for exist tells me this:
NAME is case insensitive on Windows systems, and case sensitive for files and folder on UNIX systems.
Can you fix it anyway? Probably, but not without writing code of your own. You can test in advance to make sure that it finds the correct file. So write your own fmction, perhaps called CSload. Have it test to see if a file exists with the name in the case specified. Be careful though, because exist itself is not case sensitive. But you should be able to read the list of all files in a directory. Then test to see, using regexp, for example, if the desired pattern has a match. If it does not, then CSload would be written to return an error. If a file exists with exactly the name as specified, then just call load.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by