How to convert sym formula to an array
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to create an array from a symbolic formula like the one shown below to make it compatible with the transfer function input format:
input:
K/(s*(s + 1)*(s + 5))
Output:
[K]
[1 6 5 0]
OR
[K; 1 6 5 0]
I have tried separating the numerator and denominator but a problem arises when I have no s term in either one of the terms, so using sym2poly, for example, would return an array of [1 0] for the numerator instead of just [K]. Is there a function that would be able to seperate the K value regardless of if it includes an s value, i.e. just recognize k as a constant?
clc,clear;
%declare symbolic
syms K s;
%control inputs
Gc= K / (s+1);
G= 1 / (s*(s+5));
%multiplies inputs
tfxn= Gc*G;
%seperates numerator and denominator
[num,den]=numden(tfxn);
%converts sym formula to array
den=sym2poly(den);
num=sym2poly(num);
%does not accept correct values
sys=tf(num,den);
0 comentarios
Respuestas (1)
Walter Roberson
el 4 de Abr. de 2023
num = sym2poly(num, s);
However you would end up with symbolic K in num and tf() cannot accept symbolic variables. It is not possible to construct a tf() with a symbolic variable
1 comentario
Walter Roberson
el 4 de Abr. de 2023
In short, if you need to use the optional second parameter to sym2poly then the output is likely to be something you cannot use with tf()
Ver también
Categorías
Más información sobre Number Theory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!