Strange problem while using Matlab structures
Mostra commenti meno recenti
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 Commenti
@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
il 11 Gen 2017
Risposta accettata
Più risposte (1)
Philip Borghesani
il 11 Gen 2017
Modificato: Philip Borghesani
il 11 Gen 2017
1 voto
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.
Categorie
Scopri di più su Data Type Identification in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!