{"id":412,"date":"2017-09-14T12:14:17","date_gmt":"2017-09-14T15:14:17","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=412"},"modified":"2017-09-14T12:14:17","modified_gmt":"2017-09-14T15:14:17","slug":"poly2str-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/poly2str-m\/","title":{"rendered":"poly2str.m"},"content":{"rendered":"<pre>function p = poly2str(c, x)\r\n\r\n% poly2str  Convert a polynomial coefficient vector to a string.\r\n%\r\n% p = poly2str(c) generates a string representation of the polynomial\r\n% whose coefficents are in the vector c.  \r\n% The default variable is 'x', unless otherwise specified by \r\n% p = poly2str(c, 's').\r\n% The coefficients are approximated, if necessary, by the rational\r\n% values obtained from rat.\r\n%\t\r\n% If x has a numeric value and the elements of c are reproduced\r\n% exactly by rat, then eval(poly2str(c)) will return the same value \r\n% as polyval(c, x).\r\n%\r\n% See also polyval, rat.\r\n\r\nif nargin &lt; 2, x = 'x'; end\r\nif all(c == 0), p = '0'; return, end\r\n\r\np = [];\r\nn = length(c);\r\nfor d = 0: n-1\r\n   if d &gt; 0\r\n      if c(n-d+1) &gt; 0\r\n         p = [' + ' p];\r\n      elseif c(n-d+1) &lt; 0\r\n         p = [' - ' p];\r\n      end\r\n   end\r\n   if c(n-d) ~= 0\r\n      if d == 1\r\n         p = [x p];\r\n      elseif d &gt; 1\r\n         p = [x '^' int2str(d) p];\r\n      end\r\n      if (abs(c(n-d)) ~= 1) | (d==0)\r\n         if d &gt; 0,\r\n            p = ['*' p];\r\n         end\r\n         [sn, sd] = rat(abs(c(n-d)));\r\n         s = num2str(sn);\r\n         if sd ~= 1, s = [s '\/' num2str(sd)]; end\r\n         p = [s p];\r\n      end\r\n   end\r\nend\r\nif n &gt; 0\r\n   if c(1) &lt; 0\r\n      p = ['-' p];\r\n   end\r\nend<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>function p = poly2str(c, x) % poly2str Convert a polynomial coefficient vector to a string. % % p = poly2str(c) generates a string representation of the polynomial % whose coefficents are in the vector c. % The default variable is &#8216;x&#8217;, unless otherwise specified by % p = poly2str(c, &#8216;s&#8217;). % The coefficients are approximated, [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-412","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/412\/revisions"}],"predecessor-version":[{"id":413,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/412\/revisions\/413"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}