Code covered by the BSD License  

Highlights from
Shared variable

Be the first to rate this file! 5 Downloads (last 30 days) File Size: 3.14 KB File ID: #24742

Shared variable

by Gary Lee

 

15 Jul 2009

Shared variable can create a alias or used as pass-by-reference argument.

| Watch this File

File Information
Description

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.data = a + 1;
end

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
shared variable Gary Lee 15 Jul 2009 11:43:19
inplace Gary Lee 15 Jul 2009 11:43:19
passbyreference Gary Lee 15 Jul 2009 11:43:19

Contact us at files@mathworks.com