MATLAB Answers

0

Newbie Table Array and UITable question

Asked by Peter Winson on 7 Sep 2019
Latest activity Commented on by Peter Winson on 11 Sep 2019
The GUI was made using App Designer. The following code, I create and initialize the property InstrumentTable at the same time and then set app.UITable.Data = app.InstrumentTable and got InstrumentaTable to show in the GUI. This is what I wanted.
properties (Access = private)
InstrumentTable = table("test", "HP1", 0, 0)
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
%app.InstrumentTable = table("test", "HP1", 0, 0)
app.UITable.Data = app.InstrumentTable
end
end
However, when I initialize InstrumentTable in the startupFcn of the app I just get a blank table: Here is the code
properties (Access = private)
InstrumentTable
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.InstrumentTable = table("test", "HP1", 0, 0)
app.UITable.Data = app.InstrumentTable
end
end
Here is the result
Can someone explain to this newbie what is going on?

  1 Comment

OK, I called tech support and they were able to replicate the problem once. But that was enough to show them that there was a problem. The work around to resolve the issue was to do a 'clear all' on the Matlab main window before I run the app.

Sign in to comment.

Products


Release

R2019a

2 Answers

Answer by Bhargavi Maganuru on 11 Sep 2019

properties (Access = private)
InstrumentTable
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.InstrumentTable = table("test", "HP1", 0, 0)
app.UITable.Data = app.InstrumentTable
end
end
This code is working fine, and output is getting as expected (table values are displayed).
In properties section, you can create custom properties for data that is shared between different parts of app and it doesn’t matter where you initialize the property.
Hope this helps!

  1 Comment

Thank you Bhargavi for the help. I've learned that the issue is intermitten and is a bug within UITable. I've posted the reply from MATLAB technical support on this problem.

Sign in to comment.


Answer by Peter Winson on 11 Sep 2019

Here is the Mathworks support reply to my problem
I am writing in reference to your Technical Support Case #03776780 regarding 'Question concerning app designer'.
I apologize for the delay in getting back to you. I have been discussing regarding the issue with the developers and it appears that the issue is a timing-related bug within the uitable function and is specifically related to the creation of the table.
We have identified three potential workarounds for you that might help in resolving the issue in R2019a.
1. Please try placing the 'drawnow' immediately before setting the Table Data. In other words, your 'startupFcn' could be the following:
function startupFcn(app)
app.InstrumentTable = table("RF SOURCE 1", "HP1", 0, 0);
drawnow;
app.UITable.Data = app.InstrumentTable;
end
After making this change, the issue did not reproduce on my computer in R2019a.
2. If the app is run and the data appears to be missing, this issue can be resolved in real-time by slightly resizing the figure. By resizing the figure, the table will regenerate and it will appear as expected.
3. In R2019a, the UITable function uses a specific infrastructure for data of type 'table'. In order to work around this bug, consider using data of a different data type, e.g. double array or cell array.
Meanwhile, I have also reported the bug to our developers and they are in the process of investigating it further with a potential fix for the next releases of MATLAB. I apologize for the inconvenience caused.
I am closing this case for now. Please write back to me if you have any further questions/ comments regarding the same. I shall be happy to reopen the case and assist you further.
Please preserve the Reference ID in further correspondence on this query. This allows our systems to automatically associate your reply to the appropriate Case.
If you have a new technical support question, please submit a new request here:
Sincerely,
Abhi Baruah
Mathworks Technical Support

  0 Comments

Sign in to comment.