フィルターのクリア

How can I pass a user defined class to a MEX-File?

3 ビュー (過去 30 日間)
Sina
Sina 2013 年 6 月 17 日
Hi, I was wondering if it is possible to pass a user defined class to the mex-file as an input? The help documentation is not clear for me, how can I have access to the data stored inside the user defined object which has a user defined class? Thanks Sina

採用された回答

James Tursa
James Tursa 2013 年 6 月 17 日
編集済み: James Tursa 2013 年 6 月 17 日
Pass it in just like any other variable.
If it is an old-style class (using @classname directory with multiple files) you can mostly treat it like a struct inside the mex file, since it is stored exactly like a struct internally (just with a different class designator). That is, you can use mxGetField and mxGetFieldByNumber to get at the class variable data. In fact, if you use the mxIsStruct function on the variable it will return true.
If it is a new classdef style object, your options for manipulating it inside a mex routine are very limited. TMW only supplies two functions for manipulating classdef object data, mxGetProperty and mxSetProperty. Unfortunately both of these functions use deep data copies to get the job done. If you want to work with the data without deep data copies you will have to use my custom mex functions, mxGetPropertyPtr and mxSetPropertySharedDataCopy. You can get mxGetPropertyPtr here:
I have not yet published mxSetPropertySharedDataCopy, but I do have the function finally working. I will try to get it published in the next week or so. Let me know if you need it.
  1 件のコメント
Sina
Sina 2013 年 6 月 17 日
Hi james; Unfortunately it's a new classdef style object. I 'll try your custom mex functions and update this post with the results Thanks Sina

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

その他の回答 (0 件)

カテゴリ

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