Finding eigenvalues in a loop matlab

299 views Asked by At

Ok this is how it's supposed to work. In the while loop eigenvalues are calculated for the increments of U in the variable lambda. The idea is to break the while loop once a real part of a variable lambda becomes positive and return the value of U for which this happens. I was trying to use a for loop to do it for a number of k1 values so that in the end I have a vector where in one column I have my k1 values and in the next column values of U for which lambda becomes positive. Hope you get the idea. The problem is that something doesn't seem to be working here and I really can't figure out what. Thanks for help

rho=1.225;
b=0.2;
m=5;
I_cg=0.05;
k1=2000;
k2=1000;
c1=10;
k_theta=2000;
c_theta=2;
c=2*b;
s=1;
x2=0.1;
xg=0.04;

M=[m -m*xg;-m*xg (m*(xg^2)+I_cg)];

kRoof = 60;
for kIndex = 0:kRoof

kStart = 2000;
k1 = kStart * kIndex;

U=0.1;
lambda=-1;
while (real(lambda)<0)
    i=1;
    U(i)=U+i;
    q=0.5*rho*U(i)^2;
    B=[((2*pi*q*s*c)/U(i))+c1 (pi*q*s*c)/(5*U(i));-pi*q*s*(c^2)/(2*U(i)) c_theta];
    C=[k1+k2 -k2*x2+(2*pi*q*s*c);-k2*x2 (k2*(x2^2)+(k_theta)-(pi*q*s*(c^2)/2))];
    A=[M B;zeros(2) M];
    D=[zeros(2) C;-M zeros(2)];
    lambda=eig(D,-A);
    i=i+1
    U=U+i
    if imag(lambda)==0
        disp(lambda)
    end
end
end
0

There are 0 answers