Strange problem while using Matlab structures
이전 댓글 표시
Hi,
I have a structure named plotLevelLiDARData with 3 columns and 365708 entries for each column. I tried to do the following steps:
1. data = plotLevelLiDARdata;
2. dataCopy = plotLevelLiDARdata;
3. data.x = dataCopy.x(chosenIndices);
4. data.y = dataCopy.y(chosenIndices);
5. data.z = dataCopy.z(chosenIndices);
On executing the last three steps (i.e., 3-5), I find that the values of all the three structure (i.e., plotLevelLiDARData ,data, dataCopy) are affected. Please see the attachment for some debug screenshots. It can be seen that the value X:365708x1 becomes x: 3126x1 as soon as I run the step 3.
The problem might be that Matlab is considering allocating the same memory pointer to the three structures. Could you please tell if there is a problem with my coding?
Thank you! Aravind
댓글 수: 2
@Aravind Harikumar: do not give us screen shots or images of code. Such images are useless. We cannot run images. We cannot search images of code. If you want help with your problem then please give us code. Code is text. We can run code when it is text.
Please edit your question and get rid of the useless images, and instead give us all of the code that we need to be able to replicate your problem. You might want to use rand or randi to create those matrices of data. Run your code. Check that it creates this issue, and then paste it into your question so that we can run it too.
Aravind Harikumar
2017년 1월 11일
채택된 답변
추가 답변 (1개)
Philip Borghesani
2017년 1월 11일
편집: Philip Borghesani
2017년 1월 11일
1 개 추천
lasdata in the file exchange is a handle class so plotLevelLiDARdata is not a structure, it is a handle class type object. With handle classes data, dataCopy, and plotLevelLiDARdata will be the same object so yes everything is shared between the variables. I suggest learning about how handle objects work.
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!