Solve Quartic Equation using root and deleting complex numbers from row
1 view (last 30 days)
Show older comments
I have a 4x5 matrix, each row being the coeffecients of a quartic equation. I use the roots function to obtain a 4x4 matrix with the roots solution. Each row has two complex numbers, not always in the same column as another row. What is the best way to delete the complex numbers and keep the solutions on the same row, just reducing the cloumn size. For example taking: [1,2,1i,2i;3,4,3i,4i;5i,6i,5,6;7i,8i,7,8] and getting[1,2;3,4;5,6;7,8]
0 Comments
Accepted Answer
Walter Roberson
on 25 Jun 2013
reshape(YourMatrix(imag(YourMatrix == 0)), 2, []) .'
6 Comments
Richard Brown
on 25 Jun 2013
Edited: Richard Brown
on 25 Jun 2013
You need to work with the transpose
At = YourMatrix.';
reshape(At(imag(At) == 0), 2, []).'
edit: Looks like Matt and I were writing the same comment at the same time
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!