Calculate roots of equations

2 views (last 30 days)
Max
Max on 17 Nov 2012
Hi at all, (firtsly sorry for bad english, probably I'll use the wrong word).
I have a matrix in which I have memorized the coefficients of polynomials:
A=[2 2 ; 3 3 ; ... ... ...]
every row rapresents a polynomial:
A1 -> A(1,:) -> 2x + 2
A2 -> A(2,:) -> 3x + 3
An...
to resolve the equation A1=0
ax + b = 0
x= - (b/a)
I do:
xA1 = - ( A(:,1) / A(:,2) );
I do it for all n rows.
Computionally this way is too expensive;
My questions are:
1. there is a command that calculates the roots of a generic equation?
2. If that command exists, Can I apply it ( with a for-cycle ) to every equations ?
If I'm not clear, please ask me... thanks

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 17 Nov 2012
Edited: Azzi Abdelmalek on 17 Nov 2012
use roots function
example
A=[1 2 1; 4 5 8; 8 9 7]
sol=cell2mat(arrayfun(@(x) roots(A(x,:)),(1:size(A,1)),'un',0))'

More Answers (0)

Categories

Find more on Multidimensional Arrays 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!