A pointer (or reference) in Matlab
by Andrew
22 Mar 2013
Get the behavior of a pointer.
|
Watch this File
|
| File Information |
| Description |
Create a pointer:
o = ptr();
Do anything you want with it:
o.d.msg = 'hi';
o.d.A = randn(10);
p = o;
p.d.msg = 'hello';
disp(o.d.msg); % 'hello'
Think of '.d.' as the C language's '->' operator. Write a function that acts on it:
function DoSomething(o)
o.d.A(end,end) = 10;
end
Make sure to delete it:
delete(o);
Since o and p point to the same object, p is now invalid just like o. |
| Required Products |
MATLAB
|
| MATLAB release |
MATLAB 8.0 (R2012b)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
|
Contact us