Saving Entries to Editable UI Table as a Variable in the Workspace

조회 수: 2 (최근 30일)
N/A
N/A 2021년 2월 10일
편집: N/A 2021년 2월 10일
I am currently working in App Designer to create a GUI. And am having trouble with saving entries of an editable UI Table as a variable in the workspace. My hope is that by saving this data, I will be able to call it in another tab within the same GUI.
The first through third photos show the coded functionalities so far. The fourth picture shows entries I would like to save. So far I have tried saving them using:
% Button pushed function: LvlgSaveFileButton
app.LvlgData = app.UITableLvlg.Value
and
% Button pushed function: LvlgSaveFileButton
function LvlgSaveFileButtonPushed(app, event)
app.LvlgData = get(app.UITableLvlg);
app.LvlgData = table2array(table(app.LvlgData));
and
% Button pushed function: LvlgSaveFileButton
function LvlgSaveFileButtonPushed(app, event)
assignin('base', app.LvlgData, app.UITableLvlg)
end
and
% Button pushed function: LvlgSaveFileButton
function LvlgSaveFileButtonPushed(app, event)
app.LvlgData = cellstr(struct2cell(get(app.UITableLvlg)))
I have also tried to follow the solution to a similar problem: https://www.mathworks.com/matlabcentral/answers/179029-how-to-save-data-of-uitable-in-workspace. But have been largely unsuccessful. Any help would be appreciated.
  댓글 수: 2
Stephen23
Stephen23 2021년 2월 10일
"My hope is that by saving this data, I will be able to call it in another tab within the same GUI. "
Rather than very messing about with other workspaces, the simple and efficient way to pass data around an App Designer GUI is to store it as an object property. Is there a particular reason why that does not work for you?
The documentation states "Using properties is the best way to share data within an app because properties are accessible to all functions and callbacks in an app". In contrast your approach is inefficient, indirect, liable to bugs, difficult to debug, and obfuscates the intent.
N/A
N/A 2021년 2월 10일
편집: N/A 2021년 2월 10일
@Stephen Cobeldick The GUI contains four tabs with different inputs in each. The final tab is used to "compile" a report of sorts and display the results of the previous tabs.
The table I initially presented is in the "Levelling Data" tab. Within the confines of the GUI, the only way I am able to display this data in the "Compile Report" tab is either through a Text Area or Table. In both instances I have tried to use the object property:
app.SurveyDataTextArea = app.UITableLvlg.Value
and
app.UITableSurveyData = app.UITableLvlg.Value
But neither have worked.

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

답변 (1개)

Mario Malic
Mario Malic 2021년 2월 10일
Hello,
This line makes you an error, UITableLvlg is a table and it doesn't have Value property.
app.LvlgData = app.UITableLvlg.Value;
Secondly, whiile properties of the app are convenient for sharing the data between the callbacks, if what you're doing is simple enough, you can obtain data from the components directly rather than saving them in another property and reusing it.
I'd highly suggest you to do few introductory examples in App Designer, it's going to help a lot.

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by