How to solve quadratic equations of nonscalar constants?

조회 수: 2 (최근 30일)
Imam
Imam 2014년 10월 22일
편집: Imam 2014년 10월 22일
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개)

카테고리

Help CenterFile Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by