フィルターのクリア

C-MEX file: I want to return an empty array, does anyone know how?

6 ビュー (過去 30 日間)
Mayela
Mayela 2015 年 8 月 18 日
回答済み: Vincent Huber 2020 年 10 月 2 日
If I assign plhs[0] = NULL; I get a warning in Matlab's command window and the output argument is not created/modified. Any attempt to create a matrix or an array with 0's dimensions causes Matlab to crash.

採用された回答

James Tursa
James Tursa 2015 年 8 月 19 日
This will return an empty 0x0 matrix:
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
plhs[0] = mxCreateDoubleMatrix( 0, 0, mxREAL );
}
If you need something else please provide more detail about what you are trying to do.
  1 件のコメント
Mayela
Mayela 2015 年 8 月 19 日
Thanks, James. It works. Best wishes, Mayela

サインインしてコメントする。

その他の回答 (1 件)

Vincent Huber
Vincent Huber 2020 年 10 月 2 日
In C++ if I call for
value = feval(mh,"myMexfunction",arg1,...)
with inside
outputs[0] = factory.createArray<double>({ 0,0 });
Matlab complains the following way:
Error using matlab.mex.MexHost/feval
Too many output arguments.

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by