Why does unexecuted code in a function still cause an "Undefined function or variable"?
Show older comments
I am getting the error "Undefined function or variable", but the function I am calling is defined and on my MATLAB path.
I am calling this function within a conditional block of another function. The conditional block is set up as follows:
function fun1()
if myCondition
fun2 = aValue
else
fun2()
end
end
When I execute "fun1", it goes into the else-block and then errors out on the line which calls "fun2".
I tried setting a breakpoint on this line and running "fun1" again. At this point, if I highlight the line "fun2()" and press F9, or copy and paste this line into my MATLAB command window, it runs successfully without an error. But if I press the buttons 'continue', 'step', or 'step in', I get the error "Undefined function or variable".
Why is this, and how can I make sure MATLAB finds the function which I have defined?
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Compiler 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!