Spontaneously deleted information from struct variable

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

Can you share for variable Par? Save it to a mat file and attach it to your post using the paperclip icon.
Otherwise, consider sharing this as a potential bug through the Contact Us page.
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...
Thanks all for the reply.
I'm attaching here the "Par" structure. But it could happed also to other structures. Maybe also tabels, but i'm not sure. I will try to investigate further.
It just happed in the GUI, never in the actual code. I'm just using the GUI to look into the data, I'm not doing any changes, the deletion just happens without me doing anything.
"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...
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.
Hi, iv'e managed to get two screenshots of this happens, but first of all to answer your questions.
Yes there are other variabels, but they are not affected by it, actually it never happend to me on any variable that is not struct. this time, I opend the variable and left the computer for 2 minuets without thuching it, and suddenly I saw this. you can see that the top-left cell is empty, but there should be a number there.
After that, if I click anywhere the line ">> Par.P(1).ID = [];" appear and the content of the cell become "[]":
As for your other questions, the session is open for about 10 hours I guess, but I finished running the last script about 3 hours ago, and havent done anything since then accept for open the variable just now.

Sign in to comment.

Answers (1)

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:
  1. 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.
  2. 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.
  3. 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.
  4. 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

Thanks for the Answer!
I will try to answer your questions:
  1. It is an issue I've been dealing with for over six months, so definitely not a problem of a specific session.
  2. I don't think that this is the problem. No code is running during the phenomena, and nothing should delete data.
  3. Again, as this problem occurs over a long period of time, I don't think it's a matter of a pressed key. Also, I can't always reproduce it, it just happens randomly.
  4. I will try to report it! thank you for your help
Amit

Sign in to comment.

Categories

Products

Release

R2023a

Asked:

on 3 Apr 2023

Commented:

on 3 Apr 2023

Community Treasure Hunt

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

Start Hunting!