- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
How can I set the solver to 'discrete', programmatically?
7 次查看(过去 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!