I keep getting this : "The following error occurred converting from sym to double: Unable to convert expression into double array."
조회 수: 3 (최근 30일)
이전 댓글 표시
This is my code for the Routh criterion , but ,as the title states, i keep getting error in line 13 : b(i) = e(2*i). I tried to fix the code using others users' suggestions but it still doesn't work. Thank you in advance.
function [k] = routhc(pol)
syms x
k = sym('k');
c = coeffs(pol,x);
e = fliplr(c);
l=length(e);
m=mod(l,2);
if m==0
a=rand(1,(l/2));
b=rand(1,(l/2));
for i=1:(l/2)
a(i)=e((2*i)-1);
b(i)=e(2*i);
end
else
e1=[e 0];
a=rand(1,((l+1)/2));
b=[rand(1,((l-1)/2)),0];
for i=1:((l+1)/2)
a(i)=e1((2*i)-1);
b(i)=e1(2*i);
end
end
%%now we generate the remaining rows of routh matrix
l1=length(a);
c=zeros(l,l1);
c(1,:)=a;
c(2,:)=b;
for m=3:l
for n=1:l1-1
c(m,n)=-(1/c(m-1,1))*det([c((m-2),1) c((m-2),(n+1));c((m-1),1) c((m-1),(n+1))]);
end
end
disp('the routh matrix:');
disp(c);
%%now we check the stablity of system
%syms k
kvalue = solve(c(:,1)>0,k,'ReturnConditions',true);
k = kvalue.conditions
end
댓글 수: 0
답변 (1개)
Harsha Priya Daggubati
2020년 5월 12일
Hi,
I tried executing the above code using the following polynomial '16*x^2 + 19*x + 11'. Your code executed with no errors, giving the following Routh matrix as a result.
>> routhc(16*x^2 + 19*x + 11)
the routh matrix:
16 11
19 0
11 0
k =
symtrue
ans =
symtrue
Could you provide me with the polynomial you are working with, so I can reproduce the same.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Stability Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!