# persistent

Persistent variable.

## Syntax

* persistent variable\_name
* persistent('variable\_name')
* persistent variable\_name1, ..., variable\_nameN

## Input argument

* variable\_name - a string: variable name.

## Description

**persistent** defines a variable defined by his name **variable\_name** as persistent in a function.

Before to use a persistent variable, it is necessary to initializ value.

## Examples

function to define:

```matlab
function r = test_persistent_function()
 persistent calls;
 if isempty(calls)
    calls = 0;
 end
 disp(['nb calls to test_persistent_function: ', int2str(calls)]);
 r= calls;
 calls = calls + 1;
end
```

calls test\_persistent\_function

```matlab
for i = 1:30
  r = test_persistent_function();
end
```

## See also

[clear](clear), [who](who), [global](global).

## History

| Version | Description     |
| ------- | --------------- |
| 1.0.0   | initial version |

## Author

Allan CORNET
