Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to clone a object

Subject: How to clone a object

From: meng long

Date: 23 Jun, 2009 07:21:01

Message: 1 of 3

In Matlab, can I clone a object?

Subject: How to clone a object

From: Sprinceana

Date: 23 Jun, 2009 08:58:02

Message: 2 of 3

"meng long" <menglong6518@yeah.net> wrote in message <h1pvot$o7o$1@fred.mathworks.com>...
> In Matlab, can I clone a object?

What object do you want to clone? Can you give details?

Subject: How to clone a object

From: meng long

Date: 15 Nov, 2009 15:30:19

Message: 3 of 3

"Sprinceana " <mihaispr@yahoo.com> wrote in message <h1q5eq$564$1@fred.mathworks.com>...
> "meng long" <menglong6518@yeah.net> wrote in message <h1pvot$o7o$1@fred.mathworks.com>...
> > In Matlab, can I clone a object?
>
> What object do you want to clone? Can you give details?

Dear Sprinceana:

I want to clone any instance of a handle classes.

Now I use a pseudo_clone defined by a method in the class 'Handle < handle'

function Clone(oObj,oCln)
oMeta = PMeta.HProp(oObj,{'Name','SetAccess','IsHandle'});
clProp = oMeta.clName;
clSetAccess = oMeta.clSetAccess;
loIsHandle = oMeta.loIsHandle;
dNoRows = oMeta.dNoRows;

for dNoR = 1:dNoRows
    if(~strcmp(clSetAccess{dNoR},'public')), continue; end
    tTmp = oObj.(clProp{dNoR});
    if(loIsHandle(dNoR))
        oCln.(clProp{dNoR}) = feval(class(tTmp));
        Clone(tTmp,oCln.(clProp{dNoR}));
    else
        oCln.(clProp{dNoR}) = tTmp;
    end
end

The function Clone can not works in your computer since many other relative methods are needed. I knows that the 'Clone' is not completed, but I can do nothing except
waiting matlab to surport clone as in C++,C#.

Look forward

meng long

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us