How to convert sym formula to an array
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2023 年 4 月 4 日
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 件のコメント
Walter Roberson
2023 年 4 月 4 日
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()
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!