필터 지우기
필터 지우기

how to pass arguments to matlab executables

조회 수: 51 (최근 30일)
shaz
shaz 2012년 11월 9일
댓글: Walter Roberson 2020년 8월 14일
i have a exe name a1.exe
now i need to run this exe using a batch file(.bat file)
i need to pass some input arguments to this exe a1.exe
how can i do this
  댓글 수: 1
shaz
shaz 2012년 11월 14일
i would like to pass the input arguments to matlab exe from batch file(.bat file).
Eg: how to write the input in batch file 'name.csv' now the 'name.csv' is read in matlab exe
next time i want change input argument in batch file from which matlab reads

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

채택된 답변

Image Analyst
Image Analyst 2012년 11월 9일
You can do it via the command line. Just use varargin as your input argument list. Then you might use deal() to parse it out into strings, or just use code like
userArg1 = varargin{1};
userArg2 = varargin{2};
and so on.
  댓글 수: 3
Kurt Stewart
Kurt Stewart 2019년 5월 8일
This solution does not explain enough could you show how you make the executable be able to take in the parameter. I am struggling with doing this for Simulink
Walter Roberson
Walter Roberson 2020년 8월 14일
You would write your entry point function in the form of
function NameForYourExecutable(varargin)
then nargin will tell you how many values you received on the command line, and varargin{1}, varargin{2} and so on refer to the individual character vectors that are received.
Each one will be a character vector; none of the varargin entries will be numeric. You would use str2double() to convert entries to numeric.
A graphical interface to build executables is described at https://www.mathworks.com/help/compiler/applicationcompiler-app.html or you can use the command line mcc
These assume that your entry point is MATLAB code. Simulink has different tools. I have not used Simulink Coder and I have not seen any information about the executable entry point for it.

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

추가 답변 (1개)

mouneshwar
mouneshwar 2020년 8월 14일
편집: mouneshwar 2020년 8월 14일
cosinder a function "FileName" that moves all folder content from one folder to other folder.. after creating executable..we can run the command from command prompt as
FileName.exe "C:\SrcDir" "D:\DestDri"
  댓글 수: 1
Image Analyst
Image Analyst 2020년 8월 14일
Yep, my answer will handle that possibility.

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

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by