How to know results
Mostra commenti meno recenti
I have a polynomial and parameters in it,
a=2, c=1, d=2 , g=0.5, k=2 , f=2
e=[2,8,5,4]
b=[1,2,3,4]
p=[ -c.*k+ (f.^2)*(e.^2)/a+2*e.*g, d.*e-(f*b.*e)/a]
roots(p)
I calculate roots of polynomial given parameter values.
But e an b parameters have vector values.
I want to know if it obtains roots for every combination of the e and b values or
it simply gets roots when e=2, b=1 , then b=8,e=2,... ?
1 Commento
Ani Asoyan
il 2 Giu 2020
Risposta accettata
Più risposte (1)
Steven Lord
il 2 Giu 2020
As written your code solves for the roots of the 7th order polynomial whose coefficients are:
p =
8 134 53 34 2 0 -5 -8
This is:
8*x^7 + 134*x^6 + 53*x^5 + 34*x^4 + 2*x^3 - 5*x - 8
If instead you want to find the roots of the four first order polynomials created by specifying each element of e and b in the expression for p, use a for loop instead.
>> for q = 1:numel(e)
p=[ -c.*k+ (f.^2)*(e(q).^2)/a+2*e(q).*g, d.*e(q)-(f*b(q).*e(q))/a]
end
p =
8 2
p =
134 0
p =
53 -5
p =
34 -8
If you want to find the roots of the sixteen first order polynomials with elements taken from e and from b (and not necessarily the same element of each vector) the easiest way is to use a double for loop.
2 Commenti
Ani Asoyan
il 2 Giu 2020
Steven Lord
il 2 Giu 2020
It is not first order as you've written it. Use one or two for loops to construct and solve the four or sixteen first order polynomials or use the explicit formula for the solution of a linear equation.
% if q*x = w then x = w./q
a=2, c=1, d=2 , g=0.5, k=2 , f=2
e=[2,8,5,4]
b=[1,2,3,4]
q = -c.*k+ (f.^2)*(e.^2)/a+2*e.*g;
w = d.*e-(f*b.*e)/a;
x = w./q % Using ./ instead of / because w and q are vectors
check = q.*x - w % Should be all 0's or close to it
Categorie
Scopri di più su Polynomials in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!