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

📄 fm_simtd.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
字号:
function fm_simtd(flag)
% FM_SIMTD generate data report in Simulink models during time
%          domain simulations
%
% FM_SIMTD(FLAG)
%       FLAG: 0 - initialize function and datas
%             1 - update variables in the Simulink model
%
%see also FM_LIB, FM_SIMSET, FM_SIMREP
%
%Author:    Federico Milano
%Date:      05-Oct-2005
%Version:   1.0.0
%
%E-mail:    fmilano@thunderbox.uwaterloo.ca
%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano
%
% Copyright (C) 2002-2006 Federico Milano

global File Path DAE Bus Settings clpsat
persistent blocks busidx

% silently exit if using command line version
if clpsat.init, return, end

% silently exit if the option of updating Simulink models during
% time domain simulations is not enforced
if ~Settings.simtd, return, end

% silently exit if there is any problem
if isempty(File.data), return, end
if isempty(findstr(File.data,'(mdl)')), return, end
if ~Settings.init, return, end

lasterr('');

switch flag

 case 'init' % initializing function

  pathlocal = pwd;
  cd(Path.data);
  filedata = File.data(1:end-5);
  open_sys = find_system('type','block_diagram');
  donotclose = 0;
  for i = 1:length(open_sys),
    if strcmp(open_sys{i},filedata),
      donotclose = 1;
      break
    end
  end
  if ~donotclose,
    open_system(filedata);
  end
  cur_sys = get_param(filedata,'Handle');
  blocks = find_system(cur_sys,'Type','block');
  %lines = find_system(cur_sys, ...
  %                    'FindAll','on', ...
  %                    'type','line');
  masks = get_param(blocks,'Masktype');
  busidx = find(strcmp(masks,'Bus'));
  cd(pathlocal)

 case 'update' % updating voltages

  %busidx = find(strcmp(masks,'Bus'));
  for i = 1:Bus.n
    valore = ['|V| = ', ...
              fvar(DAE.V(i),7), ...
              ' p.u.\n<V  = ', ...
              fvar(DAE.a(i),7), ...
              ' rad '];
    set_param(blocks(busidx(i)),'AttributesFormatString',valore);
  end

 otherwise

  % silently do nothing

end

⌨️ 快捷键说明

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