简体   繁体   中英

How to determine input sequence in c-mex s-function?

I am implementing a c-mex sfunction in simulink for accelerating the multiplication of two matrices. So far it is working, but I found out that the input ordering/sequence is depended of the naming schema of the connected eg constants. I attached two pictures for explanation: First, I named the inputs Constant and Constant1. Then, the input sequence is as expected. 在此处输入图片说明 When changing Constant to Constant2, the input sequence changes and therefore, my c-mex function is not correct. 在此处输入图片说明 Now, my question is how could I change this behaviour? If it is not possible how can I implement a workaround, because the ordering for matrix multiplication is in general very important.

I found a solution. When you also print the port in mdlSetInputPortDimensionInfo, you see that depending of the naming schema, the sequence of the calling is different. My workaround is to set the output port dimension in mdlSetDefaultPortDimensionInfo based on the InputDimension I read back with ssGetInputPortDimensionSize.

The complete code can be found at Github: https://github.com/steffenmauch/Simulink-Eigen3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM