Is MATLAB case sensitive in all aspects?

14 visualizaciones (últimos 30 días)
Anchal Kariwala
Anchal Kariwala el 3 de Feb. de 2019
Comentada: madhan ravi el 3 de Feb. de 2019
t=0:1;
plot(sin(t),'linewidth',3)
If MATLAB is case-sensitive then how "linewidth" is accepted instead of "LineWidth"?

Respuesta aceptada

John D'Errico
John D'Errico el 3 de Feb. de 2019
Editada: John D'Errico el 3 de Feb. de 2019
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 comentario
madhan ravi
madhan ravi el 3 de Feb. de 2019
+1 John D'Errico explained smoothly and clearly.

Iniciar sesión para comentar.

Más respuestas (1)

madhan ravi
madhan ravi el 3 de Feb. de 2019
Editada: madhan ravi el 3 de Feb. de 2019
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 .

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by