home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS2.DI$ / PERT_MAT.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.2 KB  |  51 lines

  1. %function [pert,maxnorm] = pert_mat(rv,blk,nrp,ncp)
  2. %    Makes matrix perturbation from row vector perturbation
  3.  
  4. function [pert,maxnorm] = pert_mat(rv,blk,nrp,ncp)
  5.  maxnorm = 0;
  6.  [nblk,x] = size(blk);
  7.  tot = 0;
  8.  for i=1:nblk
  9.   if blk(i,2) == 0
  10.     tot = tot + 1;
  11.   else
  12.     tot = tot + blk(i,1)*blk(i,2);
  13.   end
  14.  end
  15.  if tot == max(size(rv))
  16.    pert = zeros(nrp,ncp);
  17.    rp=1;
  18.    cp = 1;
  19.    loc = 1;
  20.    for i=1:nblk
  21.     if blk(i,2) == 0
  22.       if abs(rv(loc)) > maxnorm
  23.         maxnorm = abs(rv(loc));
  24.       end
  25.       pert(rp:rp+blk(i,1)-1,cp:cp+blk(i,1)-1) = ...
  26.          rv(loc)*eye(blk(i,1));
  27.       loc = loc + 1;
  28.       rp = rp + blk(i,1);
  29.       cp = cp + blk(i,1);
  30.     else
  31.       tmp = zeros(blk(i,1),blk(i,2));
  32.       for j=1:blk(i,1)
  33.         tmp(j,:) = rv(loc:loc+blk(i,2)-1);
  34.         loc =  loc + blk(i,2);
  35.       end
  36.       ntmp = norm(tmp);
  37.       if ntmp > maxnorm
  38.         maxnorm = ntmp;
  39.       end
  40.       pert(rp:rp+blk(i,1)-1,cp:cp+blk(i,2)-1) = tmp;
  41.       rp = rp + blk(i,1);
  42.       cp = cp + blk(i,2);
  43.     end
  44.    end
  45.  else
  46.    error('inconsistent block and perturbation data')
  47.  end
  48.  pert = pert/maxnorm;
  49. %
  50. % Copyright MUSYN INC 1991,  All Rights Reserved
  51.