mwArray& varargin initialize

조회 수: 7 (최근 30일)
mat
mat 2011년 11월 23일
function plotSignals(varargin)....end
I use mcc to convert it to C++ syntax. varargin is a variable parameter,it can receive dynamic parameters,but in MFC type of varargin is mwArray, how can I initialize this variable? I need to convert three strings to varargin.
I have tried this:
const char* str2[]={"EngSpeed","CurrentGear","filename"};
mwArray my_struct(3,1,3,str2);
but it doesnot make a difference....
Thank you for your help!

채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 11월 23일
You need to create a cell array as follows:
mwArray input(1, 3, mxCELL_CLASS);
mwArray arg1("EngSpeed");
mwArray arg2("CurrentGear");
mwArray arg3("filename");
input.Get(1,1).Set(arg1);
input.Get(1,2).Set(arg2);
input.Get(1,3).Set(arg3);
Also, this Technical Solution explains the answer with an example.
  댓글 수: 1
mat
mat 2011년 11월 26일
Thank you for your kind help, it works!
I find the description of varargin and varargout in Matlab compiler guide:
"If your MATLAB function interface uses varargin or varargout, you must
pass them as cell arrays. For example, if you have N varargins, you need
to create one cell array of size 1-by-N. Similarly, varargouts are returned
back as one cell array. The length of the varargout is equal to the number
of return values specified in the function call minus the number of actual
variables passed. As in the MATLAB software, the cell array representing
varagout has to be the last return variable (the variable preceding the first
input variable) and the cell array representing varargins has to be the last
formal parameter to the function call."

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

추가 답변 (1개)

Jan
Jan 2011년 11월 23일
varargin is a function, therefore I cannot imagine, why or how ou could initialize it. varargin replies a cell and perhaps you want to create a {1 x 3} cell vector and insert the three strings.
  댓글 수: 1
mat
mat 2011년 11월 23일
the definition of this fuction is:
extern LIB_plotSignals_CPP_API void MW_CALL_CONV plotSignals(const mwArray& varargin);
I need to input dynamic parameters through varargin.Now I have to input three strings, but I don't know how to do it correctly

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

카테고리

Help CenterFile Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by