How to Transfer new data from app designer to matlab code?

23 views (last 30 days)
Hello together. I can't solve my problem already 2 weeks. I have a code in Matlab, which calls a App Designer window :
app=app8;
app.UITable.Visible = 'off'
app.UITable2.Visible = 'off'
app.UITable3.Visible = 'off'
app.UITable4.Visible = 'off'
app.VerbindungsdatenLabel.Visible = 'off'
app.KnotendatenLabel.Visible = 'off'
app.TransformatordatenLabel.Visible = 'off'
app.BezugswertenLabel.Visible = 'off'
app.DatenbertragenButton.Visible = 'off'
After that I enter data in 4 tables and I want to get 4 cell arrays in my matlab code with these new data tables after that. But i don't understand how? My matlab code can't see variables from app designer code view.
If I ad somethin like VD=app.UITable.Data in my Matlab code I get KD =[] because app.UITable.Data not existing yet.
I tried to make CallBack in Matlab code, but it doesn't working also.
function toMLButtonPushed(app, event)
VD=app.UITable.Data
KD=app.UITable2.Data
T=app.UITable3.Data
BW=app.UITable4.Data
end
Please help me. What should I do? My Matlab is 2017.

Answers (1)

NIVEDITA MAJEE
NIVEDITA MAJEE on 29 Jun 2022
Hi Angelina,
You can use the following piece of code in your callback to the "to ML" button:
function toMLButtonPushed(app, event)
TableData = app.UITable.Data; %the data from the table which you want to save
[file,path] = uiputfile('*.mat');
save([path,file],'TableData');
end
This will allow you to write your table data in a mat file. The callback to the button will open a dialog box to save your data wherever you wish to. You can then load it to the workspace.
Also make sure to handle the situation when someone clicks on the Cancel button or tries closing the Save window using the cross button. You will get an error "Argument must be a text scalar". You can make use of a try catch block in your code.
Hope this helps!

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!