Iterate through custom bus datatype fields CMex
조회 수: 7 (최근 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에서 String에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!