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

11 vues (au cours des 30 derniers jours)
Gideon Edward le 22 Mar 2023
Modifié(e) : Luca Ferro le 22 Mar 2023
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.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Luca Ferro le 22 Mar 2023
Modifié(e) : Luca Ferro le 22 Mar 2023
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
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by