How to solve an expression with multiple variables using input values substitution?

5 ビュー (過去 30 日間)
sirbu sunny
sirbu sunny 2020 年 7 月 30 日
編集済み: Shishir Reddy 2024 年 12 月 26 日
I have a long 5th degree polynomial in S with numerator and denominator expressions. It however has several other variables such as R1,L1,L2,C1 so on. I would like to solve the expression for a given input values of the variables R1,L1, etc. The answer will however be still be an equation in S (a transfer function). How do I implement this in matlab.
A simplified example would be as follows:
expression is: R1L2 + L1*C2^2*S + (2L1-C1R1)*S^2
I can give input: R1=1, L1=2, L2=2.5, C1=1.5, C2=3
Then the output will be: 2.5 + 18S + 2.5S^2
the end goal is to be able perform ilaplace and fplot on the output (which is supposed to be a transfer function), as shown here. I am guessing that means the output expression above needs to be in or converted to symbolic form for me to do rest of the operations.

回答 (1 件)

Shishir Reddy
Shishir Reddy 2024 年 12 月 26 日
編集済み: Shishir Reddy 2024 年 12 月 26 日
Hi Sunny
To solve this problem in MATLAB, symbolic math can used to substitute the given values into the polynomial expression, and then operations like the inverse Laplace transform and plotting are performed. Here's how you can achieve this.
1. Define the symbolic variables and expression.
syms S R1 L1 L2 C1 C2
expression = R1*L2 + L1*C2^2*S + (2*L1 - C1*R1)*S^2
expression = 
2. Substitute the given values into the expression.
R1_val = 1;
L1_val = 2;
L2_val = 2.5;
C1_val = 1.5;
C2_val = 3;
expression_substituted = subs(expression, [R1, L1, L2, C1, C2], [R1_val, L1_val, L2_val, C1_val, C2_val])
expression_substituted = 
3. Perform inverse Laplace transform
time_domain_expression = ilaplace(expression_substituted, S);
disp(time_domain_expression);
For more information regarding syms, kindly refer the following documentation -
I hope this helps.

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by