File Exchange

image thumbnail

Shared variable

version (3.14 KB) by Gary Lee
Shared variable can create a alias or used as pass-by-reference argument.


Updated 15 Jul 2009

View License

This is a helper class which can be used to create a shared object. A shared object works like normal data types but can create a alias variable or use as pass-by-reference argument.

For example:
a = shared([1:10]);
b = a;
b(10) = 0; %% a(10) will get 0 too.
inplace_incr(b) %% a(1:10) will be increased too.

function inplace_incr(a) = a + 1;

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux