Skip to content

Instantly share code, notes, and snippets.

@0xff07
Last active October 19, 2016 13:43
Show Gist options
  • Save 0xff07/2497573baa0d312f68c72123c6ee5a24 to your computer and use it in GitHub Desktop.
Save 0xff07/2497573baa0d312f68c72123c6ee5a24 to your computer and use it in GitHub Desktop.
%首先定義有哪些符號。
%syms資料型態表示後面的東西是個「symbol」,再在運算時會使用代數規則,而不是計算數值。
%因為要畫間題目,所以一本上題目有什麼,這裡就定義什麼符號。
syms Ka;
syms s;
syms K1;
syms R;
syms T;
%把G打進去,並且找出開路轉移函數Gc
G = 9/(s^2 + 2*0.2*3*s + 9);
G = simplify(expand(G));
Gc = simplify(expand(Ka * G));
%找出閉路轉移函數:
H = simplify(expand((Gc)/(1 + K1*Gc)));
%計算對Ka與K1的sensitivity:
S_HKa = simplify(expand(diff(log(H), Ka, 1)*Ka));
S_HK1 = simplify(expand(diff(log(H), K1, 1)*K1));
pretty(S_HKa)
pretty(S_HK1)
%計算Y。以觀察T對Y的影響:
Y =simplify(expand(R * H + T / Ka * H));
pretty(Y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment