Large matrix in Embedded Matlab in Simulink

2 Ansichten (letzte 30 Tage)
Magnus
Magnus am 11 Mär. 2011
I am working with a simulation in simulink of a robot that uses a laserscanner to position it self. The kinematics is made in Simulink and for positioning a Embedded Matlab fcn is called each sample. The Embedded Matlab fcn contains the code for the laser scanner. The the laser scanner needs a map that now is loaded from the workspace using the constant block, with sample time put to 'inf'. The constant block is then conected directly to the Embedded Matlab fcn.
The problem is that the map is a large int8 matrix and slows down the system. It seems as the Embedded Matlab fcn loads the file from the constant block each sample. Can't I somehow make the map a global variable or something so that the Embedded Matlab fcn doesn't load it each time. Or get the Embedded Matlab fcn to work against the Matlab workspace, where the map is located.
Best regards Magnus

Antworten (4)

Arnaud Miege
Arnaud Miege am 11 Mär. 2011
Pass your matrix as a parameter to the Embedded MATLAB function rather than an input. It should then pick it up from the MATLAB workspace. More details on how set parameter arguments in Embedded MATLAB function blocks in the documentation.
HTH,
Arnaud

Magnus
Magnus am 11 Mär. 2011
Thanks for your answer!
I have tried the above method and also unchecked tunable. But the performance doesn't improve at all. It must be that it copies the parameter from the workspace each time the function is run.

Arnaud Miege
Arnaud Miege am 11 Mär. 2011
OK. The other thing to try is to remove some of the debugging and diagnostics, see Speeding Up Simulation in the documentation for more details. Also worth having a look at Speeding Up Simulation with the Basic Linear Algebra Subprograms (BLAS) Library.

Magnus
Magnus am 11 Mär. 2011
Isn't there any Simulink M-function that can use static (global) variables so that they doesn't reaload it each time the funbction is called. I am quite sure that the Embedded MATLAB function does reload the parameters. Due to even when I don't operate on the variable in the function it takes long time to execute.
How do you do when you operate on images. Isn't that possible from an own function in simulink? I can't find any other tool in the image processing toolbox.
  1 Kommentar
Arnaud Miege
Arnaud Miege am 11 Mär. 2011
I'm not sure, sorry. You may want to ask technical support:
http://www.mathworks.co.uk/support/contact_us/index.html
Arnaud

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Model Import finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by