Lapack in Simulink Real-Time Desktop

3 vues (au cours des 30 derniers jours)
Stefano Lovato
Stefano Lovato le 1 Déc 2022
Is the LAPACK library included in the Simulink Real-Time Desktop?
More specifically, I built a C S-function to integrate\ a large dynamical system having form:
Unfortunately, I cannot invert the matrix A analytically because large. The solution was to solve the linear system for inside the S-function by using the LAPACK function dgesv. I was able to generate the mex file of the S-function for the standard simulation mode in Simulink, in particular by including the mwlapack library in the mex compilation flags.
Now, I would like to try the Simulink Real-Time Desktop. The code generation and building works, but at the end I had the following error
Error occurred while executing External Mode MEX-file 'sldrtext': Error loading real-time image: undefined symbol "dgesv_"
My thinking was that I have to include the LAPACK library. I tried to include mwlapack in the Simulink libraries but it does not work (library not found in search directories).

Réponses (1)

Jan Houska
Jan Houska le 2 Déc 2022
Hi Stefano,
to be able to use some library with Simulink Desktop Real-Time, the library must be available in source form (C or C++) and the library code must be compilable for real-time operation. I don't think this is the case with LAPACK and I'm afraid LAPACK will not be usable for creating real-time code.
At this point, you have two options. Either you can use Simulink Desktop Real-Time in Connected IO mode. In this mode, your Simulink model runs uncompiled, your S-function runs as-is, and I/O operations are performed by Simulink Desktop Real-Time blocks. While the overall performance is not as high as with compiled code, it may work very well if the sample rate of the model is not too high. This is probably what I'd try first.
Or, you can also rewrite your set of equations to a Simulink model using no S-function or LAPACK - just using the integrators, gains, nonlinearities, etc. If your model follows the equation you have outlined, this should be possible, but, depending on the complexity and size of the model, it may be a lot of work. However, your model will then be compilable and will be able to run with the highest performance available.
Good Luck, Jan

Produits


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by