Why would a function call fail due to a variable not being available?

1 view (last 30 days)
I have a function call inside a nested loop as part of a larger function:
function1(argin)
for i=1:n
for j=1:m
Calculate Variable
Call function2(Variable)
end
end
end
The function2 call returns an error because the Variable defined on the line preceding the function call is not available to the function. I have confirmed via break points that the variable is calculated correctly - the function call on the next line simply sees an empty array. I am baffled....
  2 Comments
dpb
dpb on 12 Nov 2014
Unfortunately, details matter...whatever it is that is the problem precisely is omitted by not having (at a minimum, it's possible more context yet might be required)--
a) the actual assignment/calculation of Variable and
b) the definition of function2 and
c) the actual error received in context
the cyclist
the cyclist on 12 Nov 2014
Echoing what dpb suggested ...
Can you trim down your functions to the bare minimum that exhibits the problem, and then post them here? (I often find that that procedure itself is often enough to identify the problem.)

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!