How to preserve data in array in function during multiple calls of it.
3 views (last 30 days)
Show older comments
Greetings,
I have a loop that calls a function that writes data into array.
For example:
function myfunction(nmax,n)
if n==1
A = zeros(1,nmax) % called only the first time
end
A(1,n)=3
end
During second call of the function, the value in the first column becomes 0, while value in the second column is valid, and so on. Also, number of columns is not nmax anymore.
How to preserve data in array during multiple calls of function?
1 Comment
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!