Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I've written the script below. I need assistance with making sure that the calculations start at 200ft/sec, increments by 50ft/sec, and then ends at 800

I've written the script below. I need assistance with making sure that the calculations start at 200ft/sec, increments by 50ft/sec, and then ends at 800 ft/sec. The issue I've seen from this is that the x0 variable that comes from [x0,u0,itrim] doesn't start at 200ft/sec, increment by 50ft/sec, and end at 800 ft/sec. It just reads and calculates from 800ft/sec. Any ideas on how I can fix this?

%Script for executing 6-DOF simulation of F-16

clear all;

format compact;

%Set F-16 Default constants

F16_constants;

%%%%%%%%%%%%%%%%%%%

% Set CG position %

%%%%%%%%%%%%%%%%%%%

constants.XCG=0.3;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Aircraft Trim Solution: Set desired trim conditions here%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Vertical flight path in deg

gamma=0.;

%Horizontal flight path in deg

chi=0.;

%Set initial altitude in ft

alt=0;

%Set initial North-South and East-West position

p_north=0.;

p_east=0.;

%Turn Rate in deg/sec

turnrate = 0.;

%Pull-up rate in deg/sec

pullup = 0.;

%Roll rate in deg/sec

rollrate=0.;

% Loop

for Speed = 200:50:800%speed starting at 200 ft/sec, incrementing by 50 ft/sec, then stopping at 800ft/sec

%Initial guess of state and control vector

phi_est=turnrate*d2r*Speed/32.17;

pndot=Speed*cos(gamma*d2r)*cos(chi*d2r);

pedot=Speed*cos(gamma*d2r)*sin(chi*d2r);

hdot=Speed*sin(gamma*d2r);

x0=[Speed;0;0;phi_est;0;chi*d2r;0.;0.;0.;p_north;p_east;alt;0.];

u0=[0.2;0;0;0];

targ_des=[0;0;0;rollrate*d2r;pullup*d2r;turnrate*d2r;0;0;0;pndot;pedot;hdot;0;0];

[x0,u0,itrim]=trimmer('f16',x0,u0,targ_des,constants);

%Trimmed state and controls are stored in x0 and u0

[A,B,C,D] = linearize('f16',x0,u0,constants);

%Linear model stored in A and B, C and D

end

%%%%%%%%%%%%%%%%%%

Trimmer function

function [x0trim,u0trim,itrim]=trimmer(acfunction,x0,u0,targ_des,constants);

%This module is used to calculate a trim (or equilibrium) condition for a dynamic model

ns=length(x0);

nc=length(u0);

x0trim=x0;

u0trim=u0;

it=0;

itmax=500;

conv=0;

disp('Trimming:')

disp('Iteration Error');

disp('------------------');

while ((it

it=it+1;

[xdot0,y]=feval(acfunction,0.,x0trim,u0trim,constants);

targvec=[xdot0;y];

targvec=targvec(constants.TRIMTARG);

targ_err=targvec-targ_des;

disp([num2str(it), ' ' ,num2str(norm(targ_err))]);

conv=1;

for k=1:ns;

if (abs(targ_err(k))>constants.TOL(k)) conv=0; end;

end;

[A,B,C,D]=linearize(acfunction,x0trim,u0trim,constants);

if (~conv);

Jac=[A B;C D];

Jac=Jac(constants.TRIMTARG,constants.TRIMVARS);

trimvec=[x0trim;u0trim];

trimvec(constants.TRIMVARS)=trimvec(constants.TRIMVARS)-0.5*pinv(Jac)*targ_err;;

x0trim=trimvec(1:ns);

u0trim=trimvec(ns+1:ns+nc);

end;

end;

if (~conv);

disp('Warning: Trim not acheived');

itrim=0;

else;

disp(['Successful Trim']);

itrim=1;

end;

return;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago