lpstr.m
上传用户:haiyisale
上传日期:2013-01-09
资源大小:3246k
文件大小:2k
源码类别:

波变换

开发平台:

Matlab

  1. function dispSTR = lpstr(P,maxLEN)
  2. %LPSTR String to display a Laurent polynomial object.
  3. %   S = LPSTR(P) returns a string S used to display 
  4. %   the Laurent polynomial P.
  5. %   S = LPSTR(P,MAXLEN) uses at most MAXLEN chars for 
  6. %   each line of the string S. The default is MAXLEN = 60.
  7. %
  8. %   Example:
  9. %      P = laurpoly(1:8,0);
  10. %      S1 = lpstr(P) , S2 = lpstr(P,90) , S3 = lpstr(P,30)
  11. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 20-Mar-2001.
  12. %   Last Revision 08-Jul-2003.
  13. %   Copyright 1995-2004 The MathWorks, Inc.
  14. %   $Revision: 1.1.6.2 $ $Date: 2004/04/13 00:38:50 $ 
  15.    
  16. if nargin<2 , maxLEN = 60; end
  17. dispSTR = [];
  18. lineSTR = '';
  19. d = P.maxDEG;
  20. c = P.coefs;
  21. nbCoefs = length(c);
  22. for k=1:nbCoefs
  23.     v = c(k);
  24.     if v~=0
  25.         if abs(v)~=1 
  26.             tmp =  num2str(abs(v),4);
  27.         else
  28.             if d~=0 , tmp = ''; else , tmp = '1'; end 
  29.         end
  30.         if v<0 , tmp = ['- ' , tmp];  elseif (nbCoefs>1) , tmp = ['+ ' , tmp]; end
  31.         
  32.         if d~=0 
  33.             if abs(v)~=1 , tmp = [tmp '*']; end
  34.             if     d<0 , tmp = [tmp 'z^(-'];
  35.             elseif d>0 , tmp = [tmp 'z^(+'];
  36.             end
  37.             tmp = [tmp , int2str(abs(d)) ') ' ];
  38.         else
  39.             tmp = [tmp ' '];
  40.         end
  41.         lineSTR = [lineSTR , tmp];
  42.         
  43.     elseif nbCoefs==1
  44.         lineSTR = [lineSTR , '0'];
  45.     end
  46.     lenlineSTR = length(lineSTR);
  47.     if (lenlineSTR>maxLEN) & (k<nbCoefs)
  48.         lineSTR = [lineSTR ,' ...'];
  49.         dispSTR = strvcat(dispSTR,lineSTR);
  50.         lineSTR = '';
  51.     end
  52.     d = d-1;
  53. end
  54. dispSTR = strvcat(dispSTR,lineSTR);