- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
How can I set the solver to 'discrete', programmatically?
6 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I want to use set_param() to set the solver-type to "Fixed-step" and solver to "discrete".
I could set the solver type by using:
myModel = 'model';
set_param(myModel, 'SolverType', 'Fixed-step')
but I receive an error with the following statement.
set_param(myModel, 'Solver', 'discrete');
The error says the following:
Invalid setting in block_diagram 'MultiplyAndAdd_harness' for parameter 'Solver'
Can anyone help me with this?
0 件のコメント
採用された回答
Hassaan
2024 年 1 月 11 日
To set the solver type for a specific block to "Fixed-step," you are on the right track with the following code:
myModel = 'model';
set_param(myModel, 'SolverType', 'Fixed-step');
However, for discrete blocks, you typically don't need to specify a solver type as you would for continuous blocks. Instead, you define the sample time for the block.
If you want to set a sample time for a specific block to make it discrete, you can use the set_param function as follows:
myModel = 'model';
blockName = 'YourBlockName'; % Replace with the name of your block
sampleTime = '0.1'; % Replace with your desired sample time (e.g., '0.1' for a discrete block with a 0.1-second sample time)
set_param([myModel '/' blockName], 'SampleTime', sampleTime);
Replace 'YourBlockName' with the name of the block for which you want to set the sample time. This will configure the block as a discrete block with the specified sample time.
Please make sure that 'discrete' is a valid option for the specific block in your Simulink model and that you are using the correct block name in the set_param function.
---------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
Feel free to contact me.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Programmatic Model Editing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!