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

📄 sb2slgzp.m

📁 数字通信第四版原书的例程
💻 M
字号:
function sb2slgzp(blkname,in,fl,cod,timer)
%SB2SLGZP converts gain-zero-pole blocks to SIMULINK.
%	SB2SLGZP(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.

% gain/zero/pole + gain/dump/frq

% Wes Wang 10/2/92 -- 10/6/92
% Copyright (c) 1990-93 by The MathWorks, Inc.
% $Revision: 1.10 $  $Date: 1993/06/09 22:09:40 $

% in = [8, code1 code2, input, output, state,....
% state / output --> order of integer for each one
%
% in(in(17)+3) --> order of denominator
% in(in(17)+4) --> order of numerator

%gain/dumping/natural frequency
if in(3) == 4
  k=0;
  if in(in(17)-1) > 0
    k=k+1;
    y0=fl(k);
  end;
  k=k+1;
  gain = fl(k);
  for i=1:in(in(17)+3) % number of denominator pairs
    k=k+2;
    dendp(i) = fl(k-1);
    denfq(i) = fl(k);
  end;
  for i=1:in(in(17)+4) % number of numerator pairs
    k=k+2;
    numdp(i) = fl(k-1);
    numfq(i) = fl(k);
  end;
  if in(in(17)-1) > 0
    %do mask here, transfer to ss
  end;
  set_param(blkname,'Numerator','num','Denominator','den',...
	'Mask Display','dpoly(num,den)',...
	'Mask Type','Gain Damps-Freqs')
  if cod(1) ~= 0
    set_param(blkname,'Sample time',num2str(timer(1)));
  end;
  temp = 'Transfer Function specified in terms of its DC gain, damping';
  temp = [temp ' ratios, and natural frequencies.|DC Gain:|Damping rat'];
  temp = [temp 'io of complex zero pairs:|Natural Frequencies of compl'];
  temp = [temp 'ex zero pairs:|Damping ratios of complex pole pairs:|N'];
  temp = [temp 'atural frequencies of complex pole pairs:'];
  set_param(blkname,'Mask Dialogue',temp);
  temp = 'num=@1;x=@2;y=@3;z(3)=1;if ~isempty(x), for i=1:length(x),';
  temp = [temp ' z(1)=1/y(i)/y(i);z(2)=2*x(i)/y(i);num=conv(num,z);end;end;'];
  temp = [temp 'den=1;x=@4,y=@5;if ~isempty(@4),for i=1:length(x),'];
  temp = [temp 'z(1)=1/y(i)/y(i);z(2)=2*x(i)/y(i);den=conv(den,z);end;end;'];
  set_param(blkname,'Mask Translate',temp);
  temp = [num2str(gain) '\/' mat2str(numdp) '\/' mat2str(numfq) '\/'];
  temp = [temp mat2str(dendp) '\/' mat2str(denfq) '\/'];
  set_param(blkname,'Mask Entries',temp);
  temp = 'GAIN DAMPS-FREQS defines a transfer function by\n(DC gain)*num(s)/den(s)';
  temp = [temp ' where\nnum(s)=((s/ZNF)^2 + 2*ZDR*s/ZNF + 1) and\'];
  temp = [temp 'nden(s)=((s/PNF)^2 + 2*PDR*s/PNF + 1).'];
  set_param(blkname,'Mask Help',temp);
elseif in(3) == 3
  %zero-pole problem
  k = 0;
  if in(in(17)-1) > 0
    k=k+1;
    y0=fl(k);
  end;
  k = k+1;
  gain = fl(k);
  den=fl(k+1:k+in(in(17)+3))';
  k=k+in(in(17)+3);
  num=fl(k+1:k+in(in(17)+4))';
  if in(in(17)-1) > 0
    % do the mask style
  else
    set_param(blkname,...
	'Zeros',mat2str(num),...
	'Poles',mat2str(den),...
	'Gain',num2str(gain));
    if cod(1) ~= 0
      set_param(blkname,'Sample time',num2str(timer(1)));
    end;
  end;
end;




⌨️ 快捷键说明

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