How do I optimize my code with respect to 4 variables (x_1 x_3 k1 k2 k3)?
1 次查看(过去 30 天)
显示 更早的评论
%%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 个评论
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 Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!