Question: 6 Persistent variables function output timeAddition (input) Input input Output output Type 1x1 double Type 1x1 double Description An integer Description An integer, which is

 6 Persistent variables function output timeAddition (input) Input input Output output

6 Persistent variables function output timeAddition (input) Input input Output output Type 1x1 double Type 1x1 double Description An integer Description An integer, which is the sum of input and a per- sistent variable that is defined in the function. See Details Details This is a really simple function that illustrates the idea that a MATLAB function is not necessarily a mathematical function. Recall that a mathematical function must always give the same result for the same input value. Our function violates this definition In this function, you will define a persistent variable (see Tips) count that records the number of times that the function has been called. This persistent variable count is initialized with 0 and incremented by 1 each time the function is called. The output of the function is simply the sum of count and input (after count has been incremented). Tips Refer to MATLAB documentations about persistent, which gives detailed instructions and examples of how a persistent variable is defined and initialized. Pay particular attention to the initialization of a persistent variable since it is more complicated than that of an ordinary variable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!