Use mldivide in SIMULINK

14 vues (au cours des 30 derniers jours)
Maximilian Binzler
Maximilian Binzler le 2 Mai 2017
I am stuck with the following Problem: I have to solve a System of linear equations:
A*x = b (where A is 25x25 Matrix and b and x are 25x1 vectors)
at every timestep of a SIMULINK model. I am currently doing so with an embedded MATLAB function Block which does simply something like this:
function x = fcn( A , b ) %#codegen
x = mldivide(A,b);
end
The Problem is that I need to get rid of the MATLAB function Block. It really feels like a stupid question but is there a possibility to execute the mldivide-order with a SIMULINK Block?
Thank you so much in advance

Réponse acceptée

Sebastian Castro
Sebastian Castro le 2 Mai 2017
Modifié(e) : Sebastian Castro le 2 Mai 2017
Since you're using a square A matrix, you should be able to use the Divide block (Simulink > Math Operations). If you set its "Multiplication" parameter to "Matrix", a divide sign means you're passing in a matrix inverse.
Sebastian
  2 commentaires
Maximilian Binzler
Maximilian Binzler le 2 Mai 2017
Thank you so much for this answer, it is really helpful! In the Matlab Documentation for mldivide is written "If A is a square matrix, A\B is roughly equal to inv(A)*B, but MATLAB processes A\B differently and more robustly." Do you know if the Simulink divide Block is as efficient as mldivide?
Christoph Wellnhofer
Christoph Wellnhofer le 18 Juil 2023
Modifié(e) : Christoph Wellnhofer le 18 Juil 2023
@Maximilian Binzler you can also use the singular value decomposition Simulink block which also works for non-square matrices and has better numerical stability.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by