Calling multiple .m files into separate function
이전 댓글 표시
function [B, H] = IsStable(polynomial)
if polynomial ~= AllNonZero(polynomial(false))
B=0;
H=[];
elseif polynomial ~= AllSameSign(polynomial(false))
B=0;
H=[];
else
H=HurwitzMatrix(polynomial);
pm = length(H);
for 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 calculate the stability of a Hurwitz Matrix by checking if the principle minors are more than zero. Any sugestions to improve the above code as it is not working when I call three separate .m files e.g. AllNonZero, AllSameSign and HurwitzMatrix? Thank you.
댓글 수: 7
Walter Roberson
2019년 3월 19일
What are you passing in as the first parameter? If you are not passing in an object or function handle, then polynomial(false) is a logical indexing request to return none of the elements of polynomial so polynomial(false) is likely to be empty.
Mughees Asif
2019년 3월 19일
Mughees Asif
2019년 3월 19일
Adam
2019년 3월 19일
You should presize your array before the for loop:
minor = zeros(1,pm);
Mughees Asif
2019년 3월 19일
Adam
2019년 3월 19일
So, as Walter asked, what are you passing in as the parameter?
Walter Roberson
2019년 3월 19일
If AllNonZero is false then isn't the matrix all 0 or at least a row of 0?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!