how define in matlab like c++
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hi i am new on matlab, i want to know who i define Constants like gravitation. in c++ it was super easy (define g=9.8) but in matlab i don't understand it.
1 comentario
James Tursa
el 15 de Ag. de 2018
Editada: James Tursa
el 15 de Ag. de 2018
If you mean something equivalent to the "const" keyword attribute for a variable, then no MATLAB does not have this capability for basic numeric variables.
Respuestas (1)
Fangjun Jiang
el 15 de Ag. de 2018
even easier
>> g=9.8
g =
9.8000
5 comentarios
Walter Roberson
el 15 de Ag. de 2018
Editada: Walter Roberson
el 15 de Ag. de 2018
See also https://www.mathworks.com/matlabcentral/answers/321973-how-to-have-presistent-physical-constants and https://www.mathworks.com/help/matlab/matlab_oop/properties-with-constant-values.html .
That is, you can create a class that has static methods that are defined as Constant. You can also create a package of functions that return constant values and import the package as needed.
Ver también
Categorías
Más información sobre Software Development Tools en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!