开发者

How to access an array of structs in simulink?

开发者 https://www.devze.com 2023-04-08 03:25 出处:网络
I have the problem, that I have to access a funktion form a dll in matlab/Simulink in the rtw. This should work with a s function, but I have the needed parameters in a array of structures organized.

I have the problem, that I have to access a funktion form a dll in matlab/Simulink in the rtw. This should work with a s function, but I have the needed parameters in a array of structures organized.

The question is now how I can reach them when I want to call my DL开发者_如何学GoL function?

Or is there a better way (e.g. level 2 Matlab files or something similar)? The pure simulation (without RTW) worked pretty well with level 2 m files but I am not able to write a tlc file for compiling them. I did not find much on the net and the documentation only about C sources.

Thanks Christian


For signals in Simulink, what you are asking for is an array of buses. There is similar support for using arrays of structs for parameters. For calling an external function, you might want to look at the legacy code tool. You might also be able to use the MATLAB function block to call your external dll.


In addition to what @MikeT says:

Generating code from Level 2 M-S-Functions is problematic. Read this: http://www.mathworks.co.uk/help/toolbox/simulink/sfg/f7-67622.html#brgscav-1

Also, M-S-functions are generally slow, because they run in the MATLAB interpreter: http://blogs.mathworks.com/seth/2010/10/28/tips-for-simulation-performance/


In the end I coded the problem in C and used an array where I defined to order of the elements. Then I wrote some interface functions to access this "virtual" struct.

This is not very good coding but the easiest way I have found and it is portable.

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消