(, ).
:
1.
Linux:
pid_wrapper.m :
function [] = pid_wrapper( parent_pid )
[~, matlab_pid] = system(['pgrep -P' num2str(parent_pid)]);
matlab_pid = strtrim(matlab_pid);
[~, matlab_args] = system(['ps -h -ocommand ' num2str(matlab_pid)]);
matlab_args = strsplit(strtrim(matlab_args));
disp(matlab_args);
% call your script with the extracted arguments in matlab_args
% ...
end
MATLAB :
matlab -nodisplay -r "pid_wrapper($$)"
MATLAB (.. , MATLAB), wrapper. MATLAB , matlab_args.
2.
, script, .
vararg_wrapper.m :
function [] = wrapper( varargin )
% all parameters can be accessed in varargin
for i=1:nargin
disp(varargin{i});
end
% call your script with the supplied parameters
% ...
end
MATLAB :
matlab -nodisplay -r "vararg_wrapper('first_param', 'second_param')"
{'first_param', 'second_param'} vararg_wrapper, script.