go_lin.m 530 B

123456789101112131415161718192021222324252627282930
  1. function [A,B,C,D] = go_lin (f,g)
  2. ## usage: [A,B,C,D] = go_lin (f,g)
  3. ##
  4. ##
  5. n_x = eval(g_nops(f)); # Number of states
  6. n_y = eval(g_nops(g)); # Number of outputs
  7. n_u = n_y;
  8. ## Create symbolic state list
  9. x = "{}";
  10. for i=1:n_x
  11. x = go_append(x,sprintf("x_%i", i));
  12. endfor
  13. ## Create symbolic input list
  14. u = "{}";
  15. for i=1:n_u
  16. u = go_append(u,sprintf("u_%i", i));
  17. endfor
  18. [A_l,A] = go_diff(f,x);
  19. [B_l,B] = go_diff(f,u);
  20. [C_l,C] = go_diff(g,x);
  21. [D_l,D] = go_diff(g,u);
  22. endfunction