Large matrix in Embedded Matlab in Simulink

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

답변 (4개)

Arnaud Miege
Arnaud Miege 2011년 3월 11일

0 개 추천

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 2011년 3월 11일

0 개 추천

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 2011년 3월 11일

0 개 추천

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 2011년 3월 11일

0 개 추천

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

Arnaud Miege
Arnaud Miege 2011년 3월 11일
I'm not sure, sorry. You may want to ask technical support:
http://www.mathworks.co.uk/support/contact_us/index.html
Arnaud

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

질문:

2011년 3월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by