Complex variable substitution using Symbolic Toolbox no working as expected.

25 ビュー (過去 30 日間)
Dave Amels
Dave Amels 2024 年 12 月 7 日 17:24
回答済み: Paul 2024 年 12 月 8 日 0:07
For the code:
% Define symbolic variables
syms R81 R79 R80 C37 C67 T z fs complex
syms w s complex
% Define the frequency-domain transfer function
h_w = -1 / ((R81 - 1i/(C37*w)) * (1/(R79 + R80) + C67*w*1i));
disp('Frequency-domain transfer function (h(w)):');
Frequency-domain transfer function (h(w)):
disp(char(h_w));
-1/((R81 - 1i/(C37*w))*(C67*w*1i + 1/(R79 + R80)))
% Substitute s = j*w into Laplace domain
s = 1i*w; % Substitute s = j*w
h_s = simplify(subs(h_w, w*1i, s));
disp('Laplace-domain transfer function (H(s)):');
Laplace-domain transfer function (H(s)):
disp(char(h_s));
-1/((R81 - 1i/(C37*w))*(C67*w*1i + 1/(R79 + R80)))
-----------
The output is the identical equation: h_w = h_s = -1/((R81 - 1i/(C37*w))*(1/(R79 + R80) + C67*w*1i)) where h_s should be h_s = - (s * C37 * (R79 + R80)) / ((R81 * s * C37 - 1) * (1 + s * C67 * (R79 + R80)));
I'm using Symbolic Math Toolbox, Version 8.5, (R2020a). Has anyone else seen this and / or what am I doing wrong?
  1 件のコメント
Walter Roberson
Walter Roberson 2024 年 12 月 7 日 18:02
syms R81 R79 R80 C37 C67 T z fs complex
Note that there is no flag named complex for syms . What you have done there is to declare a symbolic variable named complex . All symbolic variables default to complex unless specifically restricted to real or positive or assume() or assumeAlso() are used.

サインインしてコメントする。

採用された回答

Paul
Paul 2024 年 12 月 8 日 0:07
% Define symbolic variables
syms R81 R79 R80 C37 C67 T z fs %complex
syms w s % complex
% Define the frequency-domain transfer function
h_w = -1 / ((R81 - 1i/(C37*w)) * (1/(R79 + R80) + C67*w*1i)),pretty(h_w)
1 - ---------------------------------------- / 1i \ / 1 \ | R81 - ----- | | --------- + C67 w 1i | \ C37 w / \ R79 + R80 /
% s = 1i*w -> w = s/1i
h_s = subs(h_w,w,s/1i),pretty(h_s)
1 - ------------------------------------- / 1 \ / 1 \ | R81 + ----- | | C67 s + --------- | \ C37 s / \ R79 + R80 /

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 12 月 7 日 18:06
s = 1i*w; % Substitute s = j*w
h_s = simplify(subs(h_w, w*1i, s));
You are asking to substitute 1i*w for w*1i . However, expressions are automatically rewritten to internal order before proceeding, so you are effectively asking to substitute w*1i for w*1i . Which of course does nothing useful.

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by