roots in Simulink
이전 댓글 표시
hy, I'm having some differences between matlab and simulink when using function roots():
"p=[1 xc b z]; xc= 0.005117782794100; b= 4.267869584093415e-008; z= -1.778279410038923e-019; roots(p);"
in matlab the result is: -0.005109429866868 -0.000008352931399 0.000000000004167
and in simulink(i put the code in a embeded matlab function): -0.005109429866875 -0.000008352927225 -0.000000000000000 I have to use the positive root but simulink does not have one. Am I doing something wrong? Does Simulink use diferent compiler? Thank you
채택된 답변
추가 답변 (2개)
Titus Edelhofer
2012년 1월 9일
Hi Cosmin,
up to roundoff error both solutions are fine. If you take the second solution and compute the polynomial within MATLAB:
r2=[-0.005109429866875 -0.000008352927225 -0.000000000000000];
p2=conv(conv([1 -r2(1)], [1, -r2(2)]), [1 -r2(3)])
% what's the difference to p?
p-p2
ans =
1.0e-017 *
0 0 -0.168584041049737 0.017782794100389
So: both solutions are equally "good"...
Titus
Muhammet Öztürk
2017년 5월 4일
I have got a similar question; I have a code polynomial as
Ka=1.8e-5; Kw=1e-14; sigma=0.0120; ksi=0.0482; %sigma=0.0608; %ksi=0.0406;
Poli=[1 Ka+ksi Ka*(ksi-sigma)-Kw -Kw*Ka]; Hcal = roots(Poli)
Matlab gives the results as correct Hcal =
-0.0482
-0.0000
0.0000
But in simulink function block I take the answer Hcal = -0.0482 + 0.0000i -0.0000 + 0.0000i -0.0000 + 0.0000i
İn simulink I can not take the correct answer. How can I solve this problem.
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!