How can I round off the coefficients of sys2 polynomial(num/den)?

num=[1 0 0];
den=[1 0 0 1];
sys=tf(num,den)
sysd=c2d(sys,0.3)
sys2=d2c(sysd)

댓글 수: 2

For background, see http://www.mathworks.com/matlabcentral/answers/10096-i-m-trying-to-convert-a-system-from-c2d-and-then-from-d2c-but-the-results-are-not-the-same-why-the
Nice catch Walter :)

댓글을 달려면 로그인하십시오.

 채택된 답변

Paulo Silva
Paulo Silva 2011년 6월 23일
Hi sadel, I see another hard question :)
num=[1 0 0];
den=[1 0 0 1];
sys=tf(num,den);
sysd=c2d(sys,0.3);
sys2=d2c(sysd);
[num,den] = tfdata(sys2);
num=round(num{:});
den=round(den{:});
sys2simple=tf(num,den)
Be carefull, in your example this code works well enough but please read the documentation about the round function!!!!!
Also take a look at round2

댓글 수: 4

For example it seems to me that by the time a coefficient reaches 1/3, that the coefficient should be kept, rather than round it down to 0.
Paulo's code does what sadel asked, but I suspect it was not the right question to have asked.
Hi guys and thank you!!! I think I will use the "round2" function.
Ok I think now it's better, isn't it?
num=[1.5 0 0];
den=[1 0 2.3346 1];
sys=tf(num,den)
sysd=c2d(sys,0.3);
sys2=d2c(sysd);
[num,den] = tfdata(sys2);
num=round(num{:}/0.0001)*0.0001;
den=round(den{:}/0.0001)*0.0001;
sys2simple=tf(num,den)
yes it's good

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Functions에 대해 자세히 알아보기

질문:

2011년 6월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by