Is MATLAB case sensitive in all aspects?

10 次查看(过去 30 天)
t=0:1;
plot(sin(t),'linewidth',3)
If MATLAB is case-sensitive then how "linewidth" is accepted instead of "LineWidth"?

采纳的回答

John D'Errico
John D'Errico 2019-2-3
编辑:John D'Errico 2019-2-3
VARIABLE and FUNCTION names are case sensitive. So Plot is different from PLOT, different from plot, if those are variables or function names.
In fact, MATLAB tries to be friendly to you, if you are a sloppy typer.
Plot(1:5,'o')
Undefined function or variable 'Plot'.
Did you mean:
>> plot(1:5,'o')
However, you show what is simply a string, in the form of a property name. Code can do anything the author wants, especially user written code. In fact, being case insensitive for property names is simply being friendly to the user of that code. You don't want code that absolutely needs case sensitive properties, for no good reason.
Field names of a structure are case sensitive of course, since again, these are essentially variable names.
A.Plot = 1;
A.PLOT = 2;
A.plot = 3;
A.ploT = 4
A =
struct with fields:
Plot: 1
PLOT: 2
plot: 3
ploT: 4
So, no, not EVERYTHING is case sensitive, but in general, MATLAB would probably be described as a case sensitive programming language because of its behavior on function names and variable names. (Note that many, many years ago, MATLAB was pretty much insensitive to case in almost all those respects.)

更多回答(1 个)

madhan ravi
madhan ravi 2019-2-3
编辑:madhan ravi 2019-2-3
Yes. Since it’s a character vector , inside the function there could be some functions internally used to match it but the commands for instance plot() etc etc are case sensitive. A detailed discussion can be found in https://stackoverflow.com/questions/2775263/how-to-deal-with-name-value-pairs-of-function-arguments-in-matlab .

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by