Two functions having the same name but one being capital?

8 ビュー (過去 30 日間)
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2022 年 12 月 6 日
Hello,
When I google it I do not find anything saying that matlab is NOT case sensitive with regard to function names (so, then I expect matlab to be case sensitive with function names). But, then I have difficulty to save two files with the same name (one being lowercase and the other one being capital). For instance, if I have a function f.m in my folder it does not let me to save another function having the name F.m . It says "f already exists ... do you want to replace it", and of course I say 'NO' but then I cannot save anything.
I hope there is a way to do this, otherwise I have to spend lots of times to ....
Thanks for your answer in advance!
BaBAK

採用された回答

Jon
Jon 2022 年 12 月 6 日
While MATLAB is case sensitive, Windows (assuming that is your operating system) is not. Since MATLAB requires that function names match file names, you can not utilize case sensitive function names.
  1 件のコメント
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2022 年 12 月 6 日
Thanks Jon!
OK. I learned that this is actually the windows issue not matlab issue (yes, I have windows).
So, I should change the function names.

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

その他の回答 (2 件)

Jakob B. Nielsen
Jakob B. Nielsen 2022 年 12 月 6 日
Well, it would appear from the evidence that Matlab is not case sensitive... I can't save duplicates of my functions with lower/upper case letters. I assume it is to keep people from accidentally naming functions almost-the-same. Can you not simply call one Fc (F-capital) and the other f? It is still visual what happens, but they have unique names...
  3 件のコメント
Stephen23
Stephen23 2022 年 12 月 6 日
編集済み: Stephen23 2022 年 12 月 6 日
" it would appear from the evidence that Matlab is not case sensitive.."
It is very easy to prove that MATLAB is in fact case-sensitive:
SQrt = @(x) 100+x;
sqrt(9)
ans = 3
SQrt(9)
ans = 109
The OP's filenames are being restricted by their OS, not by MATLAB.
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2022 年 12 月 6 日
Nice proof!

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


Bruno Luong
Bruno Luong 2022 年 12 月 6 日
編集済み: Bruno Luong 2022 年 12 月 6 日
"Well, it would appear from the evidence that Matlab is not case sensitive... "
No MATLAB is case sensitive
"I can't save duplicates of my functions with lower/upper case letters. "
You can save them in different folders to work around Windows limitation. Not a cleanest solution but it should work if you insist.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by