Code covered by the BSD License  

Highlights from
A pointer (or reference) in Matlab

4.0 | 1 rating Rate this file 3 Downloads (last 30 days) File Size: 1.29 KB File ID: #40907 Version: 1.0

A pointer (or reference) in Matlab


Andrew (view profile)


Get the behavior of a pointer.

| Watch this File

File Information

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;
Make sure to delete it:
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   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
07 Jan 2014 Val Schmidt  

Contact us