📄 sb2sldly.m
字号:
function sb2sldly(blkname,in,fl,cod,timer)
%SB2SLDLY converts time delay blocks to SIMULINK.
% SB2SLDLY(BLKNAME,IN,FL,COD,TIMER) converts a SystemBuild block
% to a SIMULINK block. BLKNAME is a string containing the name of
% the block. The parameters are set up for this block based on the
% SystemBuild file coding integer IN and real number FL.
%
% COD is a three dimensional vector. The first element indicates
% whether it is a continuous (0) or discrete (1) time system.
% The second element indicates whether it does not need (0) or
% does need (1) a mask. The third element indicates the
% orientation of the block.
%
% TIMER is designed for discrete time only. The first element of
% TIMER is the sampling time. The second element is the initial time.
% Wes Wang 10/2/92 -- 10/6/92
% Copyright (c) 1990-93 by The MathWorks, Inc.
% $Revision: 1.8 $ $Date: 1993/06/09 22:09:40 $
% in = [8, code1 code2, input, output, state,....
% state / output --> order of integer for each one
% if input > output --> resettable
% (input - 1)/output - 1 = highest order resettable
% This one works the same for continuous or discrete time systems.
%
% 4:7
if in(2) == 4 & in(3) == 7
delay = fl(1);
initi = fl(2:in(5)+1)';
end;
if in(4) <= 1 & in(5) <=1
if in(2) == 4 & in(3) == 7
if cod(1) == 0
set_param(blkname,'Delay Time',num2str(delay),...
'Initial Input',num2str(initi));
else
set_param(blkname,'Sample time',num2str(delay),...
'x0',num2str(initi));
end;
end;
else
for i=1:in(4)
if in(2) == 4 & in(3) == 7
if cod(1) == 0
add_block('built-in/Transport Delay',[blkname '/Fcn' num2str(i)]);
set_param([blkname '/Fcn' num2str(i)],'Delay Time',num2str(delay),...
'Initial Input',num2str(initi(i)));
sh = 'Transport\nDelay';
else
add_block('built-in/Unit Delay',[blkname '/Fcn' num2str(i)]);
set_param([blkname '/Fcn' num2str(i)],'Sample time',num2str(delay),...
'x0',num2str(initi(i)));
sh = 'Unit\nDelay';
end;
set_param([blkname '/Fcn' num2str(i)],...
'position',[160,75*i-50,275,75*i-10]);
set_param([blkname '/input' num2str(i)],'Port',num2str(i),...
'position',[50,75*i-40,70,75*i-20]);
autoline(blkname,['input' num2str(i) '/1'], ['Fcn' num2str(i) '/1']);
if ~(in(2) == 11 & in(3) == 7)
set_param([blkname '/output' num2str(i)],'Port',num2str(i),...
'position',[380,75*i-40,400,75*i-20]);
autoline(blkname,['Fcn' num2str(i) '/1'], ['output' num2str(i) '/1']);
end;
end;
end;
set_param(blkname,'Mask Display',sh);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -