MATLAB Answers

Sharing Data between Apps (App Desginer)

43 views (last 30 days)
MSP
MSP on 19 May 2018
Answered: Ahmed SAIMI on 16 Mar 2019
Hi,
i am trying to create an App using Appdesigner, which should have more than 1 window. My idea after reading some similar questions was to create a public function and call it from my second app (2 window). When calling this function, a matrix with all information that is needed would be "transferred" to my second app. The same i would do to transfer the data back to the 1 app.
My Function: Name of the 1st App: App1
methods (Access = public)
function SharedData = getData(app)
SharedData = app.App1Data;
end
end
and to call it in the 2 app i tried using: Name of the 2nd App: App2
SharedData = getData(APP1);
app.App2Data = SharedData;
And to open the 2nd App I just used run App2 in the App1 script (after pressing Button) When I analyse my app.App2Data, it is empty an no Data was "transferred".
I know that there is a "Share Data Within App Designer Apps" topic, but i am using Matlab 2017a and that functionallity (ADD Input Arguments) was implementend on Matlab 2017b.
Does anyone knows how to share Data between Apps? or can help me to make it work? Or send me an good example how to do that? i saw some examples but i need something that works and is easy to understand.
Thanks in advance, MP

Answers (2)

WSS
WSS on 11 Nov 2018
I found this while looking https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html#mw_b4d7e3b6-7641-40a6-8dd3-148c03c77298

Ahmed SAIMI
Ahmed SAIMI on 16 Mar 2019
greeting,
plz i try to how to share data between two apps in app designer
i folowed the exemples
it dosn't help me in my probleme , i need a simple easy exemple, of sharing TextArea.Value from 1st app to passe it to use it in the seconde app
in the first app code i try to stock the value of app.TextArea.Value and use it in the seconde app
properties (Access = public)
Filepath
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
% app.DATAGENUIFigure.Position = [500 400 297 137];
end
% Button pushed function: GeneratRotorDataButton
function GeneratRotorDataButtonPushed(app, event)
[FileName,PathName] = uigetfile('*.mat','Select the Rotor DATA file Path');
file=fullfile(PathName,FileName);
app.TextArea.Value=file;
load (file, 'rotortype')
handles.rotortype=rotortype;
rotortype=handles.rotortype;
app.Filepath=file;
if rotortype==1
ISOTROPDATAGEN
else
end
the seconde app code i need to load a .mat file automatecly without uigetfile window (Filepath is the path of my file to load)
function startupFcn(app)
load(app.DATAGEN.Filepath)
plzzzzzzz help me

Community Treasure Hunt

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

Start Hunting!