如何找到模型中所有的连续模块? 

8 views (last 30 days)
MathWorks Support Team
MathWorks Support Team on 17 Sep 2020
我的模型中有连续模块和离散模块,但我希望用定步长求解器(fixed step solver)。此时仿真会报错提示需要将连续模块改为离散模块,可是我该如何找到所有的连续模块呢?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Sep 2020
有两个方法:
方法一:Simulink.BlockDiagram.getInitialState 命令
这里有一个例子:
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
执行后的结果为:
'ex_execution_order/car dynamics/Integrator'
即,这个积分模块是模型中唯一的连续模块
方法二:sldebug和states命令
这里有一个例子:
open_system(docpath(fullfile(docroot, 'toolbox','simulink','examples','ex_execution_order')))
sldebug(gcs)
此时模型会进入debug模式,继续执行 states,会显示:
(sldebug @0): >> states
Continuous States for 'ex_execution_order':
等等内容,根据 Continuous States 的信息可知,积分模块是模型中唯一的连续模块。

More Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!