File mttroot/mtt/bin/trans/dm2fr_m artifact 1f2439c8d4 part of check-in 22c8905b17


#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: dm2fr_m

# Transformation: descriptor matrix to frequency response

# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.3  1996/08/11 19:08:08  peter
## Parameter passing now enabled.
##
## Revision 1.2  1996/08/11 09:32:12  peter
## Now takes the numpar parameters correctly
##
## Revision 1.1  1996/08/10 14:11:11  peter
## Initial revision
##
###############################################################

echo Creating $1_fr.m
echo Creating $1_lmfr.m
echo Creating $1_lpfr.m
echo Creating $1_nyfr.m
echo Creating $1_nifr.m

if [ "$2" = "" ]; 
then
  PARAMS='w=logspace(-1,2,100); u0=ones(nu,1);'
  echo Using default parameter $PARAMS
else
  PARAMS=$2;
fi

$MATRIX << EOF > dm2fr_m.log

  [nx,ny,nu,nz,nyz] = $1_def;
  $PARAMS

  %Defaults
  if exist('w')==0
    w = logspace(-1,2,100);
  end;

  if exist('u0')==0
    u0 = ones(nu,1);
  end;

  [n,m]=size(w);
  if m>n
    w=w';
  end;

  [A,B,C,D,E] = $1_dm($1_numpar);
  fr = dm2fr(A,B,C,D,E,w,u0);
  lw = log10(w);
  lmfr = log10(abs(fr));
  pfr = angle(fr)*180/pi;

% Complex frequency response
  write_matrix([w fr], '$1_fr');

% Log magnitude v log frequency
  write_matrix([lw lmfr], '$1_lmfr');

% Angle v log frequency
  write_matrix([lw pfr], '$1_lpfr');

% Nyquist style
  re = real(fr);
  im = imag(fr);
  nyq = [re(:,1) im(:,1)];
  for i = 2:ny
    nyq = [nyq re(:,i) im(:,i)]
  end;
  write_matrix(nyq, '$1_nyfr');

% Nichols style
  re = lw;
  im = pfr;
  nic = [im(:,1) re(:,1)];
  for i = 2:ny
    nic = [nic im(:,i) re(:,i)]
  end;
  write_matrix(nic, '$1_nifr');

EOF



MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]