g2o_pol.m 585 B

123456789101112131415161718192021222324252627
  1. function o_pol = g2o_pol (g_pol, object)
  2. ## usage: o_pol = g2o_pol (g_pol)
  3. ##
  4. ## Converts a ginsh polynomial to an octave polynomial
  5. ## Both o_pol and g_pol are strings
  6. ## o_pol can be an argument to eval
  7. if nargin<1
  8. error("usage: o_pol = g2o_pol (g_pol)");
  9. endif
  10. if nargin<2
  11. object="s";
  12. endif
  13. g_pol = g_expand(g_pol);
  14. n = g_degree(g_pol, object);
  15. n = eval([n,";"]);
  16. o_pol = "";
  17. for i=n:-1:0
  18. pol_i = g_coeff(g_pol,object,int2str(i));
  19. o_pol = sprintf("%s %s", o_pol, pol_i);
  20. endfor
  21. o_pol = sprintf("[%s ];", o_pol);
  22. endfunction