Advertisement
Guest User

Matlab ko zna koji

a guest
Dec 15th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 6.37 KB | None | 0 0
  1. >> A = [1 1 ; 4 -2]
  2.  
  3. A =
  4.  
  5.      1     1
  6.      4    -2
  7.  
  8. >> B = [1 -1; 1 -1]
  9.  
  10. B =
  11.  
  12.      1    -1
  13.      1    -1
  14.  
  15. >> D = 0
  16.  
  17. D =
  18.  
  19.      0
  20.  
  21. >> Co = ctrb(A,B)
  22.  
  23. Co =
  24.  
  25.      1    -1     2    -2
  26.      1    -1     2    -2
  27.  
  28. >> unicon_states = length(A) - rank(Co)
  29.  
  30. unicon_states =
  31.  
  32.      1
  33.  
  34. >> Ob = obav(A,B)
  35. Undefined function or variable 'obav'.
  36.  
  37. Did you mean:
  38. >> Ob = obsv(A,B)
  39.  
  40. Ob =
  41.  
  42.      1    -1
  43.      1    -1
  44.     -3     3
  45.     -3     3
  46.  
  47. >> Ob = obav(A,C)
  48. Undefined function or variable 'C'.
  49.  
  50. >> Ob = obav(A,Co)
  51. Undefined function or variable 'obav'.
  52.  
  53. Did you mean:
  54. >> Ob = obsv(A,Co)
  55. Error using obsv (line 28)
  56. In the "obsv(A,C)" command, the A matrix must be square with as many columns as C.
  57.  
  58. >> unicon_states = length(A) - rank(B)
  59.  
  60. unicon_states =
  61.  
  62.      1
  63.  
  64. >> unicon_states = length(A) - rank(Co)
  65.  
  66. unicon_states =
  67.  
  68.      1
  69.  
  70. >> Co = ctrb(A,B)
  71.  
  72. Co =
  73.  
  74.      1    -1     2    -2
  75.      1    -1     2    -2
  76.  
  77. >> unicon_states = length(A) - rank(Co)
  78.  
  79. unicon_states =
  80.  
  81.      1
  82.  
  83. >> Ob = obav(A,Co)
  84. Undefined function or variable 'obav'.
  85.  
  86. Did you mean:
  87. >> Ob = obsv(A,Co)
  88. Error using obsv (line 28)
  89. In the "obsv(A,C)" command, the A matrix must be square with as many columns as C.
  90.  
  91. >> Ob = obsv(A,Co)
  92. Error using obsv (line 28)
  93. In the "obsv(A,C)" command, the A matrix must be square with as many columns as C.
  94.  
  95. >> Ob = obsv(A,B)
  96.  
  97. Ob =
  98.  
  99.      1    -1
  100.      1    -1
  101.     -3     3
  102.     -3     3
  103.  
  104. >> neosmotrivaStanja = length(A) - rank(Ob)
  105.  
  106. neosmotrivaStanja =
  107.  
  108.      1
  109.  
  110. >> Gs = tf([1 0], 1)
  111.  
  112. Gs =
  113.  
  114.   s
  115.  
  116. Continuous-time transfer function.
  117.  
  118. >> num1 = [2,0]; den1 = [4,1];
  119. >> num2 = [3]; den2=[5,1];
  120. >> Gs1=tf(num1,den1);
  121. >> Gs2=tf(num2,den2);
  122. >> Gs = [Gs1, Gs2]
  123.  
  124. Gs =
  125.  
  126.   From input 1 to output:
  127.     2 s
  128.   -------
  129.   4 s + 1
  130.  
  131.   From input 2 to output:
  132.      3
  133.   -------
  134.   5 s + 1
  135.  
  136. Continuous-time transfer function.
  137.  
  138. >> %prvi deo nije nesto tacan za Co
  139. >> num = {[1 1]; 1}; den = {[1 2 2]; [1 0]};
  140. >> Gs = tf(num,den)
  141.  
  142. Gs =
  143.  
  144.   From input to output...
  145.            s + 1
  146.    1:  -------------
  147.        s^2 + 2 s + 2
  148.  
  149.        1
  150.    2:  -
  151.        s
  152.  
  153. Continuous-time transfer function.
  154.  
  155. >> numd = [1 0.5]; dend = [1,1.5,2]; Tsd = 0.4;
  156. >> Ob = obav(A,Co)
  157. Undefined function or variable 'obav'.
  158.  
  159. Did you mean:
  160. >> Ob = obsv(A,Co)
  161. Error using obsv (line 28)
  162. In the "obsv(A,C)" command, the A matrix must be square with as many columns as C.
  163.  
  164. >> Ob = obsv(A,Co)
  165. Error using obsv (line 28)
  166. In the "obsv(A,C)" command, the A matrix must be square with as many columns as C.
  167.  
  168. >> Gz = tf(numd, dend, Tsd)
  169.  
  170. Gz =
  171.  
  172.       z + 0.5
  173.   ---------------
  174.   z^2 + 1.5 z + 2
  175.  
  176. Sample time: 0.4 seconds
  177. Discrete-time transfer function.
  178.  
  179. >> s = tf('s');
  180. >> Gs = s/(s^2 + 2*s + 10);
  181. >> Gs = tf([1 0], [1 2 10]);
  182. >> F = [0,1; -4,-2];
  183. >> G = [0;-2];
  184. >> H = [1,0];
  185. >> D = [0];
  186. >> ss1 = ss(F,G,H,D)
  187.  
  188. ss1 =
  189.  
  190.   a =
  191.        x1  x2
  192.    x1   0   1
  193.    x2  -4  -2
  194.  
  195.   b =
  196.        u1
  197.    x1   0
  198.    x2  -2
  199.  
  200.   c =
  201.        x1  x2
  202.    y1   1   0
  203.  
  204.   d =
  205.        u1
  206.    y1   0
  207.  
  208. Continuous-time state-space model.
  209.  
  210. >> ss1.a
  211.  
  212. ans =
  213.  
  214.      0     1
  215.     -4    -2
  216.  
  217. >> F = [-1 0; 0 -1];
  218. >> G = [1;0];
  219. >> H = eye(2);
  220. >> D = zeros(2,1);
  221. >> sys = ss(F,G,H,D,0.4)
  222.  
  223. sys =
  224.  
  225.   a =
  226.        x1  x2
  227.    x1  -1   0
  228.    x2   0  -1
  229.  
  230.   b =
  231.        u1
  232.    x1   1
  233.    x2   0
  234.  
  235.   c =
  236.        x1  x2
  237.    y1   1   0
  238.    y2   0   1
  239.  
  240.   d =
  241.        u1
  242.    y1   0
  243.    y2   0
  244.  
  245. Sample time: 0.4 seconds
  246. Discrete-time state-space model.
  247.  
  248. >> %ss2tf, tf2ss, tf2zp, ss2zp, c2d, d2c, size [*broj izlaza i ulaza sistema]
  249. >> sys = ss(F,G,H,D)
  250.  
  251. sys =
  252.  
  253.   a =
  254.        x1  x2
  255.    x1  -1   0
  256.    x2   0  -1
  257.  
  258.   b =
  259.        u1
  260.    x1   1
  261.    x2   0
  262.  
  263.   c =
  264.        x1  x2
  265.    y1   1   0
  266.    y2   0   1
  267.  
  268.   d =
  269.        u1
  270.    y1   0
  271.    y2   0
  272.  
  273. Continuous-time state-space model.
  274.  
  275. >> tf(sys)
  276.  
  277. ans =
  278.  
  279.   From input to output...
  280.          1
  281.    1:  -----
  282.        s + 1
  283.  
  284.    2:  0
  285.  
  286. Continuous-time transfer function.
  287.  
  288. >> [num, den] = ss2tf(F,G,H,D,1) %poslednji argument broj izlaza
  289.  
  290. num =
  291.  
  292.      0     1     1
  293.      0     0     0
  294.  
  295.  
  296. den =
  297.  
  298.      1     2     1
  299.  
  300. >>
  301. >> [num,den] = mason{'zadatak.net', 1, 7}
  302. Undefined variable "mason" or class "mason".
  303.  
  304. >> [num,den] = mason('zadatak.net', 1, 7)
  305.      1     1     2
  306.      2     2     3
  307.      3     3     4
  308.      4     4     5
  309.      5     5     6
  310.      6     6     7
  311.      7     2     4
  312.      8     2     5
  313.      9     6     5
  314.     10     6     4
  315.     11     6     3
  316.  
  317.     '(1)'    '(-3)'    '(1/z)'    '(1/z)'    '(1/z)'    '(1)'    '(2)'    '(1)'    '(-6)'    '(-12)'    '(-8)'
  318.  
  319.  
  320. -- Network Info --
  321. Net File   : zadatak.net
  322. Start Node : 1
  323. Stop Node  : 7
  324.  
  325. ----- Paths -----
  326. P1 : 1 2 3 4 5 6
  327. P2 : 1 7 4 5 6
  328. P3 : 1 8 5 6
  329.  
  330. - Order 1 Loops -
  331. L11 : 3 4 5 11
  332. L12 : 4 5 10
  333. L13 : 5 9
  334.  
  335. The variables returned are strings describing
  336. the numerator and Denominator of the transfer equation.
  337. If you have the symbolic toolbox, use Denominator=sym(Denominator)
  338. and Numerator=sym(Numerator) to make these symbolic equations.
  339. You can now use simple(Numerator/Denominator) to boil the whole
  340. thing down. You could also use simple(Numerator) to simplify the
  341. Numerator on it' own.
  342.  
  343.  
  344. num =
  345.  
  346. ((((1)*(-3)*(1/z)*(1/z)*(1/z)*(1)*(1)-0)+(1)*(2)*(1/z)*(1/z)*(1)*(1)-0)+(1)*(1)*(1/z)*(1)*(1)-0)
  347.  
  348.  
  349. den =
  350.  
  351. 1-((1/z)*(1/z)*(1/z)*(-8)+(1/z)*(1/z)*(-12)+(1/z)*(-6))
  352.  
  353. >> num = sym(num)
  354.  
  355. num =
  356.  
  357. 1/z + 2/z^2 - 3/z^3
  358.  
  359. >> den = sym(den)
  360.  
  361. den =
  362.  
  363. 6/z + 12/z^2 + 8/z^3 + 1
  364.  
  365. >> Gz = simplify(num/den)
  366.  
  367. Gz =
  368.  
  369. (z^2 + 2*z - 3)/(z + 2)^3
  370.  
  371. >> %odrediti nule i polove ove prenosne funkcije i da se ispita upravljivost i osmotrivost ovog sistema
  372. >> [num,den] = numden(Gz)
  373.  
  374. num =
  375.  
  376. z^2 + 2*z - 3
  377.  
  378.  
  379. den =
  380.  
  381. (z + 2)^3
  382.  
  383. >> [F,G,H] = tf2ss(sym2poly(num), sym2poly(den))
  384.  
  385. F =
  386.  
  387.     -6   -12    -8
  388.      1     0     0
  389.      0     1     0
  390.  
  391.  
  392. G =
  393.  
  394.      1
  395.      0
  396.      0
  397.  
  398.  
  399. H =
  400.  
  401.      1     2    -3
  402.  
  403. >> C = ctrb(F,G)
  404.  
  405. C =
  406.  
  407.      1    -6    24
  408.      0     1    -6
  409.      0     0     1
  410.  
  411. >> upravljivost = length(F) - rank(C)
  412.  
  413. upravljivost =
  414.  
  415.      0
  416.  
  417. >> %jeste upravljiva jer ima nula neupravljivih stanja
  418. >> O = obav(F,H)
  419. Undefined function or variable 'obav'.
  420.  
  421. Did you mean:
  422. >> O = obsv(F,H)
  423.  
  424. O =
  425.  
  426.      1     2    -3
  427.     -4   -15    -8
  428.      9    40    32
  429.  
  430. >> neosmotrivastanja = length(F) - rank(O)
  431.  
  432. neosmotrivastanja =
  433.  
  434.      0
  435.  
  436. >>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement