Using table cells as output field in GUI & loading background variables

조회 수: 1 (최근 30일)
Brian
Brian 2015년 11월 13일
답변: Sudhanshu Bhatt 2015년 11월 18일
Hello all!
I am constructing a GUI (with guide), in which values from multiple "editable text fields" are taken for computations. I want the resultant values to be displayed in my GUI. Aside from displaying them as static text, is it possible to display them in the default table cells instead? This would make my GUI much more organized.
Another more general question, if I wish to load background variables in my GUI, where is the best location (which callback) to do so? Ideally I want to avoid putting them at the button callback because the same files will be reloaded.
Thank you so much!

답변 (1개)

Sudhanshu Bhatt
Sudhanshu Bhatt 2015년 11월 18일
Hi Brian,
Scenario 1:
If you have an existing UITABLE called "T1", representing some data and want to display the computed output in a separate UITABLE called "T2", with only one column named as "Output",that can be done using the code below:
% Example
f = figure('Position', [100 100 752 250]);
a = [10 20 30 40 50 60 70 80 90 100];
T1 = uitable('Parent', f, 'Position', [25 50 700 75], 'Data', a);
T2 = uitable('Parent', f, 'Position', [100 180 78 40], 'Data', sum(a));
T2.ColumnName={'Output'};
T2.RowName = [];
Scenario 2:
If, for example you want to display the sum of all values of a column in the current UITABLE, you can do this by adding a row at the end of the current UITABLE.
More information on this can be found in the MATLAB Answers Thread below:
For your second question, it is possible to use a "CreateFcn" callback which is invoked when MATLAB creates an object. You can use the callback to load the required variables when the GUI window appears.
More information on callbacks can be found in the documentation link below:
Hope this helps.
Thanks
Sudhanshu Bhatt

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by