roots in Simulink
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (2)
Titus Edelhofer
le 9 Jan 2012
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
le 4 Mai 2017
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.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!