Is it possible to use function name as name of a variable?
4 views (last 30 days)
Show older comments
for example sin = 1 is allowed, however I do not know is it correct or not? or myfunc = 2, if I have previously defined a myfunc() function. For example in case of sin = 1, sin() is also accepted, since sin is a scalar ([1]), but what if myfunc() has no parameters, this causes ambiguity?
1 Comment
Stephen23
on 25 Feb 2015
Edited: Stephen23
on 25 Feb 2015
It is a really really bad idea to do this:
sin = 1
because then you cannot call the function sin. Calling sin(1) gets the first element of the variable named sin, but because of this (bad) assignment it now has nothing to do with the function sin and only refers to the variable. Really bad idea. Just because something is possible does not make it a good idea to do it.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!