Problem 815. Persistent Usage

This Challenge is to implement the Matlab Persistent variable capability.

Given a sequence of Calls to a function return the current input summed with the prior function call input.

On the first call return the current input.

Input: a (value)

Output: b where b=a+"previous a"


    Input  Sequence: 1 2 -3 3 5
    Output Sequence: 1 3 -1 0 8

Related Challenge is Global.

Solution Stats

37.5% Correct | 62.5% Incorrect
Last solution submitted on Oct 20, 2016

Problem Comments


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more