clear all; close all; clc;airspeed = 200;windspeed = 15;angleofattack = 15*(pi/180);sideslip = 10*(pi/180);roll = 12*(pi/180);pitch = 6*(pi/180);yaw = 0*(pi/180);airspeed_vector= [200;0;0];windspeed_vector = [0;15;0];[bankangle,flightpathangle]=... navigation_to_wind(angleofattack,sideslip,roll,pitch,yaw)[groundspeed_vector, navigation_airspeed_vector]=... wind_to_navigation(airspeed_vector, windspeed_vector,... angleofattack, sideslip, roll, pitch, yaw) %
%Stuck here, trying to use Euler method to integrate
%navigation_airspeed_vector over a time of 60 seconds with a .01 step
x0=0;%initial value for x
y0=navigation_airspeed_vector;%initial value for y (3x1 double)
xn=60;%final vaule for x(where we want to end up)
h=0.01;%This is the choice of h that changes for different parts
n=(xn-x0)/h;x=zeros(n+1,1);y=zeros(n+1,1);x(1)=x0;y(1)=y0;%%Can't figure out how to assign the 3x1 matrix to this variable,
%I'm sure it has something to do with y being a 6000x1 matrix but I can't
%figure out what to do to fix it.
for k=1:n x(k+1)=x(k)+h; y(k+1)=y(k)+h*(x(k)*y(k)); disp(y);endfunction [bankangle,flightpathangle]=... navigation_to_wind(angleofattack,sideslip,roll,pitch,yaw)Cwindtobody = [cos(angleofattack)*cos(sideslip), -cos(angleofattack)... *sin(sideslip), -sin(angleofattack); sin(sideslip), cos(sideslip),... 0; sin(angleofattack)*cos(sideslip), -sin(angleofattack)... *sin(sideslip), cos(angleofattack)]^(-1); Cbodytonavigation = [cos(pitch)*cos(yaw), cos(pitch)*sin(yaw),... -sin(pitch); sin(roll)*sin(pitch)*cos(yaw)-cos(roll)*sin(yaw),... sin(roll)*sin(pitch)*sin(yaw)+cos(roll)*cos(yaw), sin(roll)... *cos(pitch); cos(roll)*sin(pitch)*cos(yaw)+sin(roll)... *sin(yaw), cos(roll)*sin(pitch)*sin(yaw)-sin(roll)... *cos(yaw), cos(roll)*cos(pitch)]; Cnavigationtowind = Cwindtobody*Cbodytonavigation;bankangle = (atan(Cnavigationtowind(2,3)/Cnavigationtowind(3,3)))*(180/pi);flightpathangle = (-asin(Cnavigationtowind(1,3)))*(180/pi);endfunction [groundspeed_vector, navigation_airspeed_vector]... = wind_to_navigation(airspeed_vector, windspeed_vector,... angleofattack, sideslip, roll, pitch, yaw)Cwindtobody = [cos(angleofattack)*cos(sideslip), -cos(angleofattack)... *sin(sideslip), -sin(angleofattack); sin(sideslip), cos(sideslip),... 0; sin(angleofattack)*cos(sideslip), -sin(angleofattack)... *sin(sideslip), cos(angleofattack)]^(-1); Cbodytonavigation = [cos(pitch)*cos(yaw), cos(pitch)*sin(yaw),... -sin(pitch); sin(roll)*sin(pitch)*cos(yaw)-cos(roll)*sin(yaw),... sin(roll)*sin(pitch)*sin(yaw)+cos(roll)*cos(yaw), sin(roll)... *cos(pitch); cos(roll)*sin(pitch)*cos(yaw)+sin(roll)... *sin(yaw), cos(roll)*sin(pitch)*sin(yaw)-sin(roll)... *cos(yaw), cos(roll)*cos(pitch)]; Cnavigationtowind = Cwindtobody*Cbodytonavigation;navigation_airspeed_vector = Cnavigationtowind^(-1)*airspeed_vector;groundspeed_vector = navigation_airspeed_vector + windspeed_vector;end
MATLAB: Trying to assign a 3×1 matrix to the 1st iteration of a for loop.
iterationmatrix
Best Answer