[Simulink] How to find different Sample Time blocks

1 view (last 30 days)
Moon
Moon on 12 Nov 2014
Answered: Orion on 12 Nov 2014
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.

Answers (1)

Orion
Orion on 12 Nov 2014
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.

Community Treasure Hunt

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

Start Hunting!