Q:

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

0

 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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

total answers (1)

Similar questions


need a help?


find thousands of online teachers now