Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Positive real root
Date: Thu, 16 Apr 2009 18:46:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <gs7uda$fkc$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1239907562 16012 172.30.248.35 (16 Apr 2009 18:46:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Apr 2009 18:46:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 816492
Xref: news.mathworks.com comp.soft-sys.matlab:533295

I have vector with complex and real roots - P. I have to write code to find only positive real root(in this calculation its only one). This is my code:
R1=1.230; X1=1.500; Xm=53.700; R2=0.787; X2=2.490; 
Vn=220; Tn=36.340;T=10; Pn=5.500; I1n=11.500; I0n=19.5; f=30;
fn=50; P=4; sn=0.036; ns=1500; P1n=6451.5;E1n=209; m=T/Tn; alfa=f/fn;
ws=157; nn=1446; wn=151.348; J=0.017; a=0.0327; b=3.112; k=1.400; 
Pag=Tn*ws; Pmag=P1n-Pag-(3*R1*I1n^2+0.005*Pn);
B=3*R1*I0n^2; C=((R1+R2)*Pag^2)/(3*E1n^2); D=Pmag;

a0=1;
a1=2*b/(1-b);
a2=(b/(b-1))^2+(2*B*(b-a)-C*m^2*(b-1)^2)/(D*alfa^k*(b-1)^2);
a3=(2*C*m^2*b)/(D*alfa^k*(b-1));
a4=-(C*m^2*b)/(D*alfa^k*(b-1)^2);

Pol=[a0 0 a1 0 a2 0 a3 0 a4];
P= roots(Pol)

Here the positive real root is 0.2968. But I don't know how to do this by code ( not to see all roots and to say - This is real positive root). Please help me.