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

  1. % function [pk,indepv,vindex] = pkvnorm(matin,p)
  2. %
  3. %   Find peak value of the norm of a VARYING matrix, also
  4. %   returns the value of the INDEPENDENT VARIABLE at the peak,
  5. %   along with the index of the INDEPENDENT VARIABLE. The second
  6. %   input argument determines the particular norm, using the same
  7. %   convention as MATLAB's NORM command.
  8. %
  9. %   See also: NORM, VNORM, and VSVD.
  10.  
  11. function [pk,iv,vindex] = pkvnorm(matin,p)
  12.  if nargin == 0
  13.    disp(['usage: [pk,iv,vindex] = pkvnorm(matin,p)']);
  14.    return
  15.  end
  16.  [mtype,mrows,mcols,mnum] = minfo(matin);
  17.  if nargin == 1
  18.    p = 2;
  19.  end
  20.  if mtype == 'cons'
  21.    pk = norm(matin,p);
  22.    vindex = [];
  23.    iv = [];
  24.  elseif mtype == 'vary'
  25.    pk = -inf;
  26.    npts = mnum;
  27.    out = zeros(npts+1,2);
  28.    ff = (npts+1)*mrows;
  29.    pt = 1:mrows:ff;
  30.    ptm1 = pt(2:npts+1)-1;
  31.    for i=1:npts
  32.      val = norm(matin(pt(i):ptm1(i),1:mcols),p);
  33.      if val > pk
  34.        pk = val;
  35.        vindex = i;
  36.        iv = matin(i,mcols+1);
  37.      end
  38.    end
  39.  elseif mtype == 'syst'
  40.    error('PKVNORM is not defined for SYSTEM matrices')
  41.    return
  42.  else
  43.    pk = [];
  44.    vindex = [];
  45.    iv = [];
  46.  end
  47. %
  48. % Copyright MUSYN INC 1991,  All Rights Reserved
  49.