[Simulink] How to find different Sample Time blocks

1 次查看(过去 30 天)
Hello
I am 2012b version user.
on simulink my model, There are two different sample time legens as below (checked using Display- Sample Time - All menu)
(Ammotation - Description - value
D1 - Discrete1 - 0.03
inf - Constant - inf)
My Model is set for discrete simulation. I'd like to find inf constant blocks to make it discrete. However, I checked almost block's sample time setteing manually, but I couldn't find the block which has inf configuration. (All annotation of arrows shows D1- Discrete message)
so, I want to know how to find the block which has the different sample time automatically or manually
Thank you in advance.

回答(1 个)

Orion
Orion 2014-11-12
Hi,
I guess you'd like something like
% get all constant block in the model
AllConstBlocks = find_system(bdroot,'BlockType','Constant');
% loop on all these block
for i = 1:length(AllConstBlocks)
% if the sample time is inf, then display the full path to the block
if strcmp(get_param(AllConstBlocks{i},'SampleTime'),'inf')
disp(AllConstBlocks{i});
end
end
you can adapt this for different kind of block, or other sample times.

类别

Help CenterFile Exchange 中查找有关 Interactive Model Editing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by