I want to pass data between two windows of GUI

16 views (last 30 days)
I want to pass data from the first window to the secod window. I am not sure how to do it since I am new to this app designer.
I already try few steps from the youtube, but the second window did not progress the output that I want.
Mainapp code:
properties (Access = private)
DialogApp % Description
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CALCULATEButton
function CALCULATEButtonPushed(app, event)
app.DialogApp = dialogapp(app);
delete(app)
end
% Value changed function: FORCEFNEditField
function FORCEFNEditFieldValueChanged(app, event)
value = app.FORCEFNEditField.Value;
end
Dialogapp code:
properties (Access = private)
CallingApp % Description
end
methods (Access = public)
function importdata(app)
app.FORCEFNEditField=force;
app.AREAAm2EditField=area;
stress = force/area;
app.STRESSFANm2EditField.Value= stress;
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app, mainapp)
app.CallingApp = mainapp;
end
end
I not sure which part I was wrong. Hope u guys can help me.

Answers (2)

Image Analyst
Image Analyst on 2 Oct 2022

Walter Roberson
Walter Roberson on 2 Oct 2022
Something closer to
Mainapp:
properties (Access = public)
force
area
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CALCULATEButton
function CALCULATEButtonPushed(app, event)
dialogapp(app);
delete(app)
end
% Value changed function: FORCEFNEditField
function FORCEFNEditFieldValueChanged(app, event)
app.force = app.FORCEFNEditField.Value;
end
function AREAAM2EditFieldValueChanged(app, event)
app.area = app.AREAAM2EditField.Value;
end
Dialogapp:
methods (Access = public)
% Code that executes after component creation
function dialogapp(mainapp)
app.stressFANM2TextField.Value = mainapp.force / mainapp.area;
end
end
  1 Comment
Wan Muzamir
Wan Muzamir on 3 Oct 2022
Which callbacks I need to use for the dialog app, is it startup or I just need to create public function?
Thank you

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!