How do I access simulation end time of Simulink model from within a MATLAB function block?
古いコメントを表示
I'm writing a MATLAB function block which would like to know how long the simulation it contains is to be run. I.e. I would like to set a variable in my MATLAB function block to be equal to whatever number the user chose as simulation end time (10 by default).
I would guess / hope that this is a simply accessible property of some object or another, but I cannot seem to find out what is it called or where to read it off.
Ideally I would like to include this block in a library to be used in different models, so it shouldn't need to have any prior information about the model it is used in.
採用された回答
その他の回答 (1 件)
Albert Ziegler
2015 年 10 月 13 日
4 件のコメント
Sebastian Castro
2015 年 10 月 13 日
編集済み: Sebastian Castro
2015 年 10 月 13 日
Yes, I didn't want to suggest that because it requires you to label get_param and str2double as extrinsic using coder.extrinsic.
This means that your function will work only in simulation; if you generate code, the code will be looking for an extrinsic definition of these 2 functions that you would need to provide.
If this block is staying in simulation world, that is completely fine.
NOTE: By the way, you could just use the bdroot function to immediately find the name of the top model ;) ... which you will also have to label as extrinsic.
- Sebastian
Albert Ziegler
2015 年 10 月 15 日
編集済み: Albert Ziegler
2015 年 10 月 15 日
Christopher Yi
2020 年 4 月 27 日
I also have the same problem, what code is that, matlab or C? cuz I put it in the Matlab function block but arose error 'Function 'get_param' not supported for code generation.'
em
2022 年 6 月 6 日
Assuming you don't actually need to use this function for code generation (perhaps just for testing), you can bypass the code generation for that function using "coder.extrinsic('get_param');"
カテゴリ
ヘルプ センター および File Exchange で Simulink Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
