home *** CD-ROM | disk | FTP | other *** search
- %function [pert,maxnorm] = pert_mat(rv,blk,nrp,ncp)
- % Makes matrix perturbation from row vector perturbation
-
- function [pert,maxnorm] = pert_mat(rv,blk,nrp,ncp)
- maxnorm = 0;
- [nblk,x] = size(blk);
- tot = 0;
- for i=1:nblk
- if blk(i,2) == 0
- tot = tot + 1;
- else
- tot = tot + blk(i,1)*blk(i,2);
- end
- end
- if tot == max(size(rv))
- pert = zeros(nrp,ncp);
- rp=1;
- cp = 1;
- loc = 1;
- for i=1:nblk
- if blk(i,2) == 0
- if abs(rv(loc)) > maxnorm
- maxnorm = abs(rv(loc));
- end
- pert(rp:rp+blk(i,1)-1,cp:cp+blk(i,1)-1) = ...
- rv(loc)*eye(blk(i,1));
- loc = loc + 1;
- rp = rp + blk(i,1);
- cp = cp + blk(i,1);
- else
- tmp = zeros(blk(i,1),blk(i,2));
- for j=1:blk(i,1)
- tmp(j,:) = rv(loc:loc+blk(i,2)-1);
- loc = loc + blk(i,2);
- end
- ntmp = norm(tmp);
- if ntmp > maxnorm
- maxnorm = ntmp;
- end
- pert(rp:rp+blk(i,1)-1,cp:cp+blk(i,2)-1) = tmp;
- rp = rp + blk(i,1);
- cp = cp + blk(i,2);
- end
- end
- else
- error('inconsistent block and perturbation data')
- end
- pert = pert/maxnorm;
- %
- % Copyright MUSYN INC 1991, All Rights Reserved
-