필터 지우기
필터 지우기

Extract numerator and denominator from transfer function without manually adding it to the program?

조회 수: 9 (최근 30일)
Hello im having a trouble where my denominator roots are very long and needed to be extracted without inserting manually in the coding.
Example this is my output
z exp(5) sin(3)
----------------------------------
2
exp(10) z - cos(3) exp(5) z 2 + 1
(exp(5)*sin(3)*((cos(3)^2*exp(10) - exp(10))^(1/2) + cos(3)*exp(5))*((cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5))*(exp(10)*hypergeom([2, -exp(-10)*((cos(3)^2*exp(10) - exp(10))^(1/2) - exp(10) + cos(3)*exp(5))], -exp(-10)*((cos(3)^2*exp(10) - exp(10))^(1/2) - 2*exp(10) + cos(3)*exp(5)), 1/w) + (cos(3)^2*exp(10) - exp(10))^(1/2)*hypergeom([2, exp(-10)*(exp(10) + (cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5))], exp(-10)*(2*exp(10) + (cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5)), 1/w) - exp(10)*hypergeom([2, exp(-10)*(exp(10) + (cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5))], exp(-10)*(2*exp(10) + (cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5)), 1/w) + (cos(3)^2*exp(10) - exp(10))^(1/2)*hypergeom([2, -exp(-10)*((cos(3)^2*exp(10) - exp(10))^(1/2) - exp(10) + cos(3)*exp(5))], -exp(-10)*((cos(3)^2*exp(10) - exp(10))^(1/2) - 2*exp(10) + cos(3)*exp(5)), 1/w) + cos(3)*exp(5)*hypergeom([2, exp(-10)*(exp(10) + (cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5))], exp(-10)*(2*exp(10) + (cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5)), 1/w) - cos(3)*exp(5)*hypergeom([2, -exp(-10)*((cos(3)^2*exp(10) - exp(10))^(1/2) - exp(10) + cos(3)*exp(5))], -exp(-10)*((cos(3)^2*exp(10) - exp(10))^(1/2) - 2*exp(10) + cos(3)*exp(5)), 1/w)))/(2*w*(cos(3)^2*exp(10) - exp(10))^(1/2)*((cos(3)^2*exp(10) - exp(10))^(1/2) - exp(10) + cos(3)*exp(5))*(exp(10) + (cos(3)^2*exp(10) - exp(10))^(1/2) - cos(3)*exp(5)))
(exp(5) sin(3) (#3 + #4) (#3 - #4) (exp(10) #1 + #3 #2 - exp(10) #2 + #3 #1 + cos(3) exp(5) #2
- cos(3) exp(5) #1))/(w #3 (#3 - exp(10) + #4) (exp(10) + #3 - #4) 2)
where
/ 1 \
#1 == F | 2, -exp(-10) (#3 - exp(10) + #4); -exp(-10) (#3 - 2 exp(10) + #4); - |
2 1\ w /
/ 1 \
#2 == F | 2, exp(-10) (exp(10) + #3 - #4); exp(-10) (2 exp(10) + #3 - #4); - |
2 1\ w /
2
#3 == sqrt(cos(3) exp(10) - exp(10))
#4 == cos(3) exp(5)
So im expecting the output to be,
num=[exp(5)*sin(3)]
den=[exp(10) -cos(3)exp(5) .....]
Thank you.

답변 (1개)

Luca Ferro
Luca Ferro 2023년 3월 22일
편집: Luca Ferro 2023년 3월 22일
supposing that your original function is defined as a transfer function model you can access its properties using dot notation.
num=tfName.Numerator; %tf name is the name of the transfer function variable
den=tfName.Denominator;
The output will be a cell array that you can then acces using curly bracket notation.
Or you coulf stright use the curly bracket notation by:
num=tfName.Numerator{:}; %tf name is the name of the transfer function variable
den=tfName.Denominator{:};
in this case the output will be a numeric array

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by