Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Alex

Posts: 14
Registered: 12/18/13
Real negative odd roots
Posted: Jan 28, 2014 8:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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
Read Real negative odd roots
Alex
1/28/14
Read Real negative odd roots
Curious

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.