MATLAB Answers

GUI briefly loading "old" data into graphs upon program initialization

6 views (last 30 days)
Hi. I have a program that runs through a GUI. When the program loads there is a brief period when it appears to be loading "old" data into figures/graphs. This old data at one point in time had been fed into the program during development. This data was pulled from an external file and then graphed, so I am not sure how it still "remembers" it as the file is no longer in the same directory as the current GUI files. I have the same issue with an old logo that was read from a png file - when the program loads for a second or so the old logo still shows up before all the graphs/figures clear and the current logo loads. Any ideas how to remove this issue? Not sure if pictures will really help, but can provide if needed. thanks! h


Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 18 Mar 2018
The data was in the figure at the time you saved the .fig file, so it will be replotted as the GUI is reinitialized.
You should go back into GUIDE and edit the properties of those axes and save the fig.


Show 8 older comments
HpW on 19 Mar 2018
Hi. I tried that but it did not work. the first line of code opens a new blank figure, and with the second and third lines I get this error
Struct contents reference from a non-struct array object.|
Any other ideas?
Walter Roberson
Walter Roberson on 19 Mar 2018
fig = GUI;
handles = guidata(fig);
HpW on 19 Mar 2018
so I ended up just deleting and re-inserting the axes again and now they work without the old data showing up on initialization. Not sure why wasn't working before but seems to be working now. thanks again for all of your help!

Sign in to comment.

More Answers (1)

Nicolás Aristimuño Padrón
Hey, I'm glad that you could solve the problem. Yesterday it happened the same to me and I saw this post and could solve it too. However, in my gui, I had the "Save" button, as well as the "Zoom" and the "hand". I accidentaly clicked on the Save button of the GUI instead of the Save button in the .fig file that contains the GUI design. Then, everything changed and started to load old data, the same data that was on the GUI when I clicked on that Save Button. Then, in order to solve it I had to reset the axes from the .m file and then click again on that Save button. This is because as the .fig file did change, then I could not solve it from there. The error source was on the GUI that calls the GUI.m file, so that should be solved from there, instead than from the .fig file. Its tricky...
Also, if you have any plot in your axes, then when reset and saving again, these axes will change their tag, so you have to put the tags again from the .fig file. Then is fine!
Hope this non-obvious error and solution can help other people. And remember to NOT include the Save button into the GUI haha


Sign in to comment.

Sign in to answer this question.


Translated by