Selecting positive or negative terms of a symbolic vector
Show older comments
I have a symbolic vector say [a^2*b^3, 0, -a*b^2, b^2, -a^4*b]. I would like to obtain two vectors from this. One of them only selecting the entries that have a positive coefficient, in this case I would like to obtain [a^2*b^3, b^2]. The other containing the entries with negative coefficient: [-a*b^2, -a^4*b].
I tried extracting the coefficients and then using if statement to create a vector with the positive entries and similar for the negative.
Is there a more efficient way to do this?
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!