How do I find all continuous blocks in a model in order to replace them to use a discrete solver?
조회 수: 25 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2020년 9월 8일
편집: MathWorks Support Team
2023년 3월 30일
I would like to see all continuous blocks at once in order to change all continuous blocks to discrete state blocks. When I switched to "Fixed Step discrete (no continuous state)" solver from "Variable Step (auto)", I get the following error:
"FixedStepDiscrete" solver cannot be used to simulate block diagram <model_name> because it contains continuous states.
채택된 답변
MathWorks Support Team
2023년 3월 28일
편집: MathWorks Support Team
2023년 3월 30일
You can find out which blocks have continuous states using either of the following two methods:
1) Use the command "Simulink.BlockDiagram.getInitialState" as follows:
open_system(docpath(fullfile(docroot, 'toolbox','simulink','examples','ex_execution_order')))
model = gcs;
states = Simulink.BlockDiagram.getInitialState(model);
if ~isempty(states)
for n=1:length(states.signals)
if strcmp(states.signals(n).label,'CSTATE')
states.signals(n).blockName
end
end
end
This is the result when running the above code:
ans =
'ex_execution_order/car dynamics/Integrator'
2) Use "sldebug('model')" and then type "states".
For example:
>> open_system(docpath(fullfile(docroot, 'toolbox','simulink','examples','ex_execution_order')))
>> sldebug(gcs)
%----------------------------------------------------------------%
[TM = 0 ] simulate(ex_execution_order)
(sldebug @0): >> states
Continuous States for 'ex_execution_order':
Idx Value (system:block:element Name 'BlockName')
0. 0 (0:0:0 CSTATE 'ex_execution_order/car dynamics/Integrator')
Discrete States for 'ex_execution_order':
Idx Value (system:block:element Name 'BlockName')
0 0 (1:0:0 DSTATE 'ex_execution_order/discrete cruise controller/Unit Delay1')
1 0 (1:5:0 DSTATE 'ex_execution_order/discrete cruise controller/Unit Delay')
(sldebug @0): >> quit
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!