copy a handle of an Array

I want a method to copy a handle of an Array not the Array Elements. like the java Arrays. for Example: X = [3 3 3]; A = handle(X); so when I change A, X will Automatically changed. so: A(2) = 0; will case that x = 3 0 3

 채택된 답변

Daniel Shub
Daniel Shub 2011년 11월 17일

0 개 추천

You cannot do it. While MATLAB supports handle classes, you cannot subclass double to be a handle class. There are a number of different ways to work around the problem, can you provide more about what you want to do?
If you are simply trying to avoid memory issues, MATLAB handles that behind the scenes and often there isn't a memory advantage between passing arrays, handles or pointers.

댓글 수: 2

Juan
Juan 2011년 11월 17일
thanx..
i tried to refer to an double array
you said:"MATLAB handles that behind the scenes and often there isn't a memory advantage between passing arrays, handles or pointers."
when i try this every time:
manuel_selected = data.selectionArrays.manuel_selected;
because i want a short variable .. do MATLAB do what u say?
Daniel Shub
Daniel Shub 2011년 11월 17일
Try it yourself. Watch a memory manager when you execute
a.x = randn(1e8, 1);
followed by
x = a.x;

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 17일

0 개 추천

Everything Daniel said is correct.
Perhaps for your purposes, you could make use of Matt J's file exchange contribution http://www.mathworks.com/matlabcentral/fileexchange/26611-on-the-fly-definition-of-custom-matrix-objects . and adapt it to your needs. You might end up needing to subclass it from the handle class to achieve your needs. I don't say that it will be easy, but if you really need it, you really need it.
Or perhaps the dataset array from the stats toolbox would meet your needs (we aren't clear yet as to what those needs are.)

댓글 수: 1

Juan
Juan 2011년 11월 17일
thank you.. i 'll read that but it look to advanced for me

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

질문:

2011년 11월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by