Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

solve an equation and get real&greater than zero root

0 views
Skip to first unread message

sudhakar bendi

unread,
Jun 7, 2010, 2:56:04 AM6/7/10
to
I am new to to matlab.Just I want to solve an equation and from those roots i want to select real&positive root.I am trying to excute a simple program,but it is showing undefined method or function 'gt' for input arguments of type 'sym'.Can u help me
anybody in this.
Program is

syms x;
x=solve('x^4+4*x^2-6400');
double(x);
for i=1:4
if(double(imag(x(i,1)))==0)&(double(real(x(i,1)>0))))
w=x(i,1)
else
w=0
end
end

John D'Errico

unread,
Jun 7, 2010, 6:04:04 AM6/7/10
to
"sudhakar bendi" <bendi_s...@yahoo.co.in> wrote in message <hui564$iav$1...@fred.mathworks.com>...

> I am new to to matlab.Just I want to solve an equation and from those roots i want to select real&positive root.I am trying to excute a simple program,but it is showing undefined method or function 'gt' for input arguments of type 'sym'.Can u help me
> anybody in this.
> Program is
>
> syms x;
> x=solve('x^4+4*x^2-6400');
> double(x);

So what do you think this last line does?

It makes a double precision number of the result, and
then throws it away! It does NOT store the result in x.

John

Walter Roberson

unread,
Jun 7, 2010, 9:16:19 AM6/7/10
to

x(i,1)>0 will be a logical value, so there is no point in taking the
real portion of it.

Perhaps you meant double(real(x(i,1)))>0

0 new messages