Modify the function func2 from Section 6.4.1 that has a persistent variable count. Instead of having the function print the value of count, the value should be returned
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:6| Question number:21.6
All Answers
total answers (1)
func2ii.m
function outc = func2ii
% Returns the value of a persistent variable
% that counts the # of times the function is called
% Format of call: func2ii or func2ii()
% Returns the value of the persistent count
persistent count
if isempty(count)
count = 0;
end
count = count + 1;
outc = count;
end
need an explanation for this answer? contact us directly to get an explanation for this answer