I want to pass data between two windows of GUI

조회 수: 20 (최근 30일)
Wan Muzamir
Wan Muzamir 2022년 10월 2일
댓글: Wan Muzamir 2022년 10월 3일
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.

답변 (2개)

Image Analyst
Image Analyst 2022년 10월 2일

Walter Roberson
Walter Roberson 2022년 10월 2일
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
Wan Muzamir
Wan Muzamir 2022년 10월 3일
Which callbacks I need to use for the dialog app, is it startup or I just need to create public function?
Thank you

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

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by