Spontaneously deleted information from struct variable
Show older comments
Hi,
I have a wierd problam. I'm using Matlab 2023a, but it also happens in 2022 a&b, so I don't think it's related to the software version.
The thing is, I have a complex structure, which has 4 fields. The first field is a cell, but all the others are also structures so that a typical value can look like this:
Par.P(1).X = 721041
The thing is that while the variable is open on the variable window (so you can see the structure table with all the data), and one of the table cells is selected, sometimes Matlab decides spontaneously to delete the content of this cell. It is followed by the following statement in the Command window (for example):
Par.P(1).FR = [];
As far as I can tell, it only happens in these complex structures, not in any other types of variables or simple structures.
Has anyone know what might be the cause of this annoying problem?
Thanks!
Amit
6 Comments
Cris LaPierre
on 3 Apr 2023
Can you share for variable Par? Save it to a mat file and attach it to your post using the paperclip icon.
dpb
on 3 Apr 2023
Do you ever have this happen with actual code, that is, other than when using the GUI interface?
I would almost bet the problem is in that tool, not in the base MATLAB structure code; maybe a spurious callback event is getting generated.
I'm such an old dog I've never adopted using all the newer bells and whistles in the UI; I'm a command-line kinda' guy so haven't ever observed such happen; I'd just avoid doing that and look at the struct content via disp() or whatever is convenient form...maybe even writing a throwaway anonymous function or two to shorten typing.
But, agree that if this is occurring and can be documented to be repeatable occurrence, then it's definitely worthy of a bug report to MathWorks; even if it is "just" an annoyance in the UI, it shouldn't be...
Amit Kallush
on 3 Apr 2023
dpb
on 3 Apr 2023
"It just happed in the GUI, never in the actual code...."
That was my supposition; a bug of that nature in actual code would have been reported previously.
My suggestion would be following @Cris LaPierre's advice with one additional condition -- the next time it occurs capture the screen displaying the issue and the specific code line echo that matches precisely the case and include it along with the actual structure at the same time.
Then, I'd also bring up commandhistory and copy the observed commands prior to that event -- to provide context that might indicate somehave specific operation been done earlier. May not be of any diagnostic use to TMW, but ya' never can tell...
They may be able to build an automated test suite that fiddles around with the GUI until it can capture an event...
Cris LaPierre
on 3 Apr 2023
Edited: Cris LaPierre
on 3 Apr 2023
When it happens, are there other variables in your workspace? Are you toggling back and forth between a script and the variable editor? Are there any actions you are performing that could be contributing? Has your session been running for a long time? Have you just finished running a script?
Just curious what state your MATLAB is in when this happens.
Amit Kallush
on 3 Apr 2023
Answers (1)
Jack
on 3 Apr 2023
0 votes
This sounds like a very strange issue that could potentially be caused by a bug in MATLAB. Here are a few suggestions that you could try to help troubleshoot and potentially solve the issue:
- Check if the issue persists in a new MATLAB session: Close MATLAB and reopen it to see if the issue still occurs. If the issue goes away in a new session, it could be a temporary problem that might have been caused by a specific operation or interaction with MATLAB.
- Check for any scripts or functions that might modify the structure: It's possible that there is a script or function that modifies the structure and could be inadvertently deleting the content of the cell. Search your codebase for any functions that modify the structure and see if any of them could be causing the issue.
- Check for any unintentional key presses: Sometimes, unintentional key presses can occur while typing or using the mouse. This could potentially cause the content of the cell to be deleted. Try to be mindful of any key presses that might occur while using MATLAB.
- Report the issue to MathWorks: If none of the above solutions work, you could consider reporting the issue to MathWorks support. They might be able to provide more insight into the issue or help you find a solution.
I hope one of these suggestions helps you solve the issue.
1 Comment
Amit Kallush
on 3 Apr 2023
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
