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

2 vues (au cours des 30 derniers jours)
Chedi Mbaga
Chedi Mbaga le 10 Fév 2021
Modifié(e) : Chedi Mbaga le 10 Fév 2021
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 commentaires
Stephen23
Stephen23 le 10 Fév 2021
"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.
Chedi Mbaga
Chedi Mbaga le 10 Fév 2021
Modifié(e) : Chedi Mbaga le 10 Fév 2021
@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.

Connectez-vous pour commenter.

Réponses (1)

Mario Malic
Mario Malic le 10 Fév 2021
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.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by