Error in while loop
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mughees Asif
el 19 de Mzo. de 2019
Comentada: Torsten
el 19 de Mzo. de 2019
function IsStable(polynomial)
if AllNonZero(polynomial) == false
H=[]
elseif AllSameSign(polynomial) == false
H=[]
else
HurwitzMatrix(polynomial);
pm = length(polynomial);
while i=1:pm
minor(i)=det(polynomial(1:i,1:i));
end
if minor(i)>0
B=1
else
B=0
end
end
I am trying to run this code but get this error,
Undefined function or variable 'minor'.
Error in IsStable (line 12)
if minor(i)>0
Any suggestions? Thank you.
0 comentarios
Respuesta aceptada
Torsten
el 19 de Mzo. de 2019
Do you want a different value for B for each minor, i.e. B(i) instead of B ?
Then use
function IsStable(polynomial)
if AllNonZero(polynomial) == false
H = []
elseif AllSameSign(polynomial) == false
H = []
else
HurwitzMatrix(polynomial);
pm = length(polynomial);
for i = 1:pm
minor(i) = det(polynomial(1:i,1:i));
if minor(i) > 0
B(i) = 1
else
B(i) = 0
end
end
end
4 comentarios
Torsten
el 19 de Mzo. de 2019
And what do you expect polynomial(1:i,1:i) to be for this polynomial ? As defined, your polynomial is a vector, not a matrix.
Más respuestas (0)
Ver también
Categorías
Más información sobre Polynomials 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!