Any advice on using matlab coder efficiently?

2 ビュー (過去 30 日間)
Michal Szkup
Michal Szkup 2020 年 4 月 6 日
編集済み: Michal Szkup 2020 年 4 月 7 日
I am trying to learn how to use matlab coder to generate mex functions in order to speed up my codes.
I read the documentation (at least parts of it and watched tutorials) so I feel I have a basic understand how the matlab coder works, but my first experience has not been encouraging (the mex code was slower than function despite a massive for-loop that I compute withing the functions). So I wonder if there is a way to write m-files that are to be translated to mex files in order to improve efficiency of mex functions? More specifically, here are my questions.
  1. Are there any don'ts for preparing m-files (in terms of coding style) that are to be converted to mex-files? For example, I read that logical indexing is slow in mex files.
  2. Is it OK passing structures to the function that is to be converted to a mex file. I have many parameters that I would like to pass and having passed them in a structure makes the code much cleaner.
  3. In m-file having a+B where a is a scalar and B is a matrix is fast. Is the same true for mex files or should I transform a into a constant matrix?
Any other advise would be much appreciated.

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by