⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copy_model.m

📁 CheckMate is a MATLAB-based tool for modeling, simulating and investigating properties of hybrid dyn
💻 M
字号:
function copy_model(src,dst)

% Copy a Simulink model
%
% Syntax:
%   "copy_model(src,dst)"
%
% Description:
%   "copy_model(src,dst)" creates a copy, "dst", of the Simulink system "src".
%
% See Also:
%   validate

% Create new system and copy the location information from the source system
new_system(dst);
location = get_param(src,'Location');
set_param(dst,'Location',location);

% Copy all blocks from the source system
blocks = get_param(src,'Blocks');
for k = 1:length(blocks)
  add_block([src '/' blocks{k}],[dst '/' blocks{k}]);
end

% Copy all lines (recursively) from the source system
lines = get_param(src,'Lines');
for k = 1:length(lines)
  copy_line(lines(k),dst)
end
return

% -----------------------------------------------------------------------------

function copy_line(line,dst)

Points = line.Points;
k = 1;
while (k < size(Points,1))
  if all(Points(k,:) == Points(k+1,:))
    Points = [Points(1:k,:); Points(k+2:size(Points,1),:)];
  else
    k = k + 1;
  end
end
if size(Points,1) > 1
  add_line(dst,Points);
end

for k = length(line.Branch):-1:1
  copy_line(line.Branch(k),dst);
end
return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -