Why does MATLAB not allow a function name to be used as a variable name inside a function, even though the variable has been previously cleared?
Mostrar comentarios más antiguos
When I use a function name such as SIN as a variable name inside another function, I cannot access the SIN function even though I clear the variable previously. If the same steps are executed in a script or at the command line, then it gives the expected result and allows access to the function.
For example, the following function when executed results in an error.
function foo
sin = 5;
clear sin;
sin(pi)
The error obtained is:
??? Reference to a cleared variable sin.
Error in ==> foo at 4
sin(pi)
Expected Result: Even if a function name is used as a variable, the clearing of this variable from the workspace should once again allow access to the said function.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Performance and Memory en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!