How do I optimize my code with respect to 4 variables (x_1 x_3 k1 k2 k3)?

조회 수: 1 (최근 30일)
Alex M
Alex M 2017년 11월 21일
댓글: Walter Roberson 2017년 11월 21일
%%Parameters
format short
% Constants
rho=1.225;
U=170;
s=1;
c=0.5;
c_2=1;
b=0.5*c;
m=5;
I_CG=0.05;
m_p=0.5;
% x_p=(0:0.01:c);
zero=[0 0; 0 0];
% Variables
x_g=0.5*c;
x_ac=0.25*c;
x_1=0.1*c;
x_3=0.7*c;
q=0.5*rho*u^2;
c_2=1;
%x_1 x_3 k1 k2 k3 have to changed in order to result in the highest u;
%k1+ k2+ k3 <30000
for u = [0:1:75]
M=[ m -m*(x_ac - x_g); -m*(x_ac - x_g) I_CG + m*(x_ac - x_g)^2 ];
E=[k1 + k2 + k3 k1*(x_1 - x_ac) + k3*(x_3 - x_ac); k1*(x_1 - x_ac) + k3*(x_3 - x_ac) k1*(x_1 - x_ac)^2 + k3*(x_3 - x_ac)^2];
B=[1+c_2/(pi*s*c*rho) c/2; 0 c^2/16];
Bbar=pi*s*c*rho*[B];
K=[0 1; 0 0];
Kbar=pi*s*c*rho*[K];
A=[[M] u*[Bbar];[zero] [M]];
C=[[zero] [E]+u^2*[Kbar] ; -[M] [zero] ];
c_2;
u;
lambda=eig(C,-A);
if any(lambda>0)
break
end
u
  댓글 수: 4
Alex M
Alex M 2017년 11월 21일
u velocities are being tested, and the best combination of the x_1 x_3 k1 k2 k3 will give me the greatest u velocity before the code reads a positive value in the eigenvector.
Walter Roberson
Walter Roberson 2017년 11월 21일
Okay.
I do not observe anything that indicates how those five variables are to be changed as you go?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by