Iterate through custom bus datatype fields CMex
6 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have some custom bus datatypes defined in my base MATLAB workspace. I now need to dynamically iterate through their fields to dynamically allocate enough memory, dynamically create structs with their structure and values, etc. pp.
My first intention was to search for a built-in function, but I couldnt find one. Then I saw the ssGetDataTypeName function, but I could not even get a value by calling mexCallMATLAB with ".Elements(1).DataType" appended to the result of the ssGetDataTypeName function. Instead an error gets thrown claiming MATLAb doesn't know a variable or function named like that.
Does anybody has a hint for me? Thanks in advance!
P.S.: Of course, all actions I try to perform from within the Simulink block succeed in the plain MATLAB environment doing it manually. There is no error like an undefined variable or a bad defined bus or something. It's working, just not dynamically.
1 件のコメント
Rik van der Struijk
2020 年 11 月 6 日
編集済み: Rik van der Struijk
2020 年 11 月 6 日
Hi Rob,
I am trying to achieve the same as you. Have you ever found an elegant solution?
回答 (1 件)
James Tursa
2014 年 6 月 10 日
If you have a struct in your mex routine (call it st) and need to get at the .Elements(1).DataType field element, you will need to do it in steps.
mxArray *Elements, *DataType; // arbitrary variable names
Elements = mxGetField(st,0,"Elements"); // first get the Elements field
Datatype = mxGetField(Elements,0,"DataType"); // then get the DataType subfield
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!