Matlab RunTime and argc/argv as input arguments of an app?
조회 수: 29 (최근 30일)
이전 댓글 표시
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
Adam Danz
2022년 10월 6일
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.
채택된 답변
Chris
2022년 11월 9일
편집: Chris
2022년 11월 9일
(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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Runtime에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!