Borrar filtros
Borrar filtros

Calculate roots of equations

1 visualización (últimos 30 días)
Max
Max el 17 de Nov. de 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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 17 de Nov. de 2012
Editada: Azzi Abdelmalek el 17 de Nov. de 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))'

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by