Azzera filtri
Azzera filtri

Calculate roots of equations

1 visualizzazione (ultimi 30 giorni)
Max
Max il 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

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 17 Nov 2012
Modificato: Azzi Abdelmalek il 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))'

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by