Fsolve cannot continue error
2 views (last 30 days)
Show older comments
I keep getting the error
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
clear vars
global g m S Iyy l alpha_t zt CL0 CLa CLq cm0 Cmd cmq CD0 K1 K...
cmap Fmax V0 nv rho0 nr Ve Cma He
g = 9.80665;
m = 120000;
S =260;
Iyy = 9.72e6;
l = 6.608;
alpha_t = -2*pi/180;
zt = 0.5;
CL0 = 0; CLa = .453;
CLq = -.7;cm0 = -.025;Cmd = -1.46;
cmq = -15; CD0=0.0175;
K1 = 0; K=0.5; cmap=-3;
Fmax- 240000; V0 =1; nv=0;
rho0=1.225;
nr=.75;
Xcg = -0.025; %use different value
n= 20 %may want to use bigger number for report
%res_alfae=zeros(n.n); res
res_alpha_e = zeros(n,n);
res_delta_e = zeros(n,n);
res_throttle_e = zeros(n,n);
i=1;
for He = linspace(7000,12000,n)
disp(i)
i1 = 1;
for Ve = linspace(222,278,n)
Cma = CLa*Xcg;
Xeq0 = [0 0 .5];
Xeq = fsolve(@equil,Xeq0,optimset('Algorithm','Levenberg-Marquardt','Display','off','MaxIter',100000,'MaxFunEvals',1000000));
res_alpha_e(i,i1) = Xeq(1);
res_delta_e(i,i1) = Xeq(2);
res_throttle_e(i,i1) = Xeq(3);
i1 = i1 + 1;
end
i = i+1;
end
figure(1); contourf(linspace(222,278,n),linspace(7000,12000,n)/1000,res_alpha_e*180/pi);
figure(2); contourf(linspace(222,278,n),linspace(7000,12000,n)/1000,res_delta_e*180/pi);
figure(3); contourf(linspace(222,278,n),linspace(7000,12000,n)/1000,res_throttle_e);
Xcg=0;
Ve=240;
Cma=CLa*Xcg;
He = 10000;
%Calculating the equilibrium condition
Xeq0=[0 0 .5];
Xeq=fsolve(@equil,Xeq0,optimset('Display','iter','MaxIter',100000,'MaxFunEvals',100000));
alphe_e = Xeq(1); delta_e = Xeq(2); throttle_e = Xeq(3);
disp('Equilibrium Condition: alpha_e, delta_e, and throttle_e');
disp([[alpha_e delta_e]*180/pi throttle_e])
tf=45
x0=[Ve 0 0 ]
[t,x]=ode45('dynamic_2D',[0 tf],x0)
V = x(:,1);
gamma = x(:,2);
alpha = x(:,3);
q = x(:,4);
H = x(:,5);
ground = V.*cos(gamma);
0 Comments
See Also
Categories
Find more on Partial Differential Equation Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!