Matlab RunTime and argc/argv as input arguments of an app?
29 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have two apps made on AppDesigner (desktop apps) and, for some reason, I want to generate separate executables files. In this context, I want to call one app from the other using the system command line.
So... I have two questions about it:
(1) Is it possible to open this new app in the same instance of Matlab RunTime (that is running the calling app)?
(2) Is it possible to read command line arguments (like argc and argv in C/C++) as input arguments of a desktop app made on AppDesigner?
4 Commenti
Adam Danz
il 6 Ott 2022
Thanks, but in this case, I may not be that helpful as I've had very limited experience with deployable apps, it's just not my forte. I don't think what you're describing in you Q1 is possible. For your Q2, are you asking how to read the MATLAB-driven command line? diary is often used to read MATLAB command history and this could be an option as it is not listed as an excluded function in compiled apps.
Risposta accettata
Chris
il 9 Nov 2022
Modificato: Chris
il 9 Nov 2022
(1) Is it possible to open this new app in the same instance of Matlab RunTime (that is running the calling app)?
I agree, doesn't seem possible for an exe, but MathWorks might know otherwise (this is also not my forte).
(2) Is it possible to read command line arguments (like argc and argv in C/C++) as input arguments of a desktop app made on AppDesigner?
Tested in R2022a
In appdesigner, make a startupFcn callback and right-click on it. You can "Edit App Input Arguments."
My prototype startup function looks like this (and I've added the corresponding Properties "arg1" and "arg2"):
function startupFcn(app, arg1, arg2)
arguments
app
arg1 = 'Hi';
arg2 = 'Ho';
end
app.arg1 = arg1;
app.arg2 = arg2;
end
Setting default values for the arguments allows you to skip them at the command line.
varargin works for this too, but you need somewhere appropriate to stick the arguments. For instance:
function startupFcn(app, varargin)
app.argv = varargin;
end
in the startupFcn, with "argv" as an app property. Simple enough.
Compile the app to a standalone desktop app. In a terminal, you can invoke it with spaces between the arguments:
./appX.exe beep boop
In Matlab, wrap the command with system:
system('./appX.exe beep boop')
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su MATLAB Runtime in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!