How to solve quadratic equations of nonscalar constants?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi guys, I have another question. So I simply want to solve a quadratic equations, well MATLAB has roots function to find the solutions.
pol = [A B C];
sol = roots(pol);
which will give you the roots of Ax^2+Bx+C = 0. However in my problem all A, B, and C are matrix of the same size, and I want to get the largest root from each set of the polynomial constant comprising the elements of the same index from A, B, and C. Which means in the end I will get a matrix with the same size of either A, B, or C containing the largest roots from each set of equation. I can do this by using 'for' loop
for i = 1:size(A,1)
for j = 1:size(A,2)
pol = [A(i,j) B(i,j) C(i,j)];
root = max(roots(pol));
end
end
But this takes tremendous amount of time since the size of matrices A and the other is very big. I'm not sure if using another solver function like fzero will cut the execution time a lot. And simply using the familiar formula for solving quadratic equations is not favorable either because there are some zero elements in matrix A. So is there a way to solve this problem without using 'for', and give reasonable speed?
I will really appreciate your help.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Quadratic Programming and Cone Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!