Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Real negative odd roots
Replies: 1   Last Post: Jan 28, 2014 11:58 AM

 Messages: [ Previous | Next ]
 Alex Posts: 14 Registered: 12/18/13
Real negative odd roots
Posted: Jan 28, 2014 8:47 AM

Hello, for any roots i need to create a script that the output will be only the real negative odd roots.

For example: rtemp = [-8 -8 -8 -8 4 -1 3]

to choose only real negative roots (there are some cases when the roots are complex, so i don't want complex roots :

rneg=[];
for i=1:length(rtemp)
if(isreal(rtemp(i)==1) && (rtemp(i)<0))
rneg = [rneg rtemp(i)];
end
end

rneg =

-8 -8 -8 -8 -1

Now i only want only the odd roots. In this example -8 is an even root (4 times) and -1 is odd, so the output will be only -1. If rtemp = [-8 -8 -8 4 -1 3], the -8 will be an odd root (3 times) so the output will be [-1 -8].
How can i write to have only the odd roots? Thank you!

Date Subject Author
1/28/14 Alex
1/28/14 Curious