Newbie Table Array and UITable question

조회 수: 2 (최근 30일)
Peter Winson
Peter Winson 2019년 9월 7일
댓글: Peter Winson 2019년 9월 11일
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
Peter Winson
Peter Winson 2019년 9월 9일
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.

댓글을 달려면 로그인하십시오.

답변 (2개)

Bhargavi Maganuru
Bhargavi Maganuru 2019년 9월 11일
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
Peter Winson
Peter Winson 2019년 9월 11일
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.

댓글을 달려면 로그인하십시오.


Peter Winson
Peter Winson 2019년 9월 11일
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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by