Clear Filters
Clear Filters

Graph wont plot or show

1 view (last 30 days)
Ella
Ella on 26 Mar 2023
Commented: Walter Roberson on 26 Mar 2023
%load in data
%
clc
taredata=readmatrix('ATP_yaw0_pitchtare_clean_elev_down.csv');
taredata=taredata(1:12,:);
yawM5=readmatrix('ATP_yawM5_pitchsweep_clean_elev_down.csv')-taredata;
yawM10=readmatrix('ATP_yawM10_pitchsweep_clean_elev_down.csv')-taredata;
yawM15=readmatrix('ATP_yawM15_pitchsweep_clean_elev_down.csv')-taredata;
yaw0=readmatrix('ATP_yaw0_pitchsweep_clean_elev_down.csv')-taredata;
yaw5=readmatrix('ATP_yaw5_pitchsweep_clean_elev_down.csv')-taredata;
yaw10=readmatrix('ATP_yaw10_pitchsweep_clean_elev_down.csv')-taredata;
yaw15=readmatrix('ATP_yaw15_pitchsweep_clean_elev_down.csv')-taredata;
%slice it and take away tare forces
tare_forces=taredata(2:12,6:11);
yawM5_forces=yawM5(2:12,6:11);
yawM10_forces=yawM10(2:12,6:11);
yawM15_forces=yawM15(2:12,6:11);
yaw0_forces=yaw0(2:12,6:11);
yaw5_forces=yaw5(2:12,6:11);
yaw10_forces=yaw10(2:12,6:11);
yaw15_forces=yaw15(2:12,6:11);
%get alpha and beta for each
alpha_all=[yawM15(2:12, 12), yawM10(2:12, 12), yawM5(2:12, 12), yaw0(2:12, 12), yaw5(2:12, 12), yaw10(2:12, 12), yaw15(2:12, 12)]
beta_all =[yawM15(2:12, 13), yawM10(2:12, 13), yawM5(2:12, 13), yaw0(2:12, 13), yaw5(2:12, 13), yaw10(2:12, 13), yaw15(2:12, 13)]
%we have balance forces
%Fx Fy Fz
%we need to convert these to aircraft forces
%Xa Ya Za
%then convert to aerodynamic forces
%D S L
%pull balance forces from excel
fx_all=[yawM15_forces(:,2), yawM10_forces(:,2), yawM5_forces(:,2), yaw0_forces(:,2), yaw5_forces(:,2), yaw10_forces(:,2), yaw15_forces(:,2)]
fy_all=[yawM15_forces(:,3), yawM10_forces(:,3), yawM5_forces(:,3), yaw0_forces(:,3), yaw5_forces(:,3), yaw10_forces(:,3), yaw15_forces(:,3)]
fz_all=[yawM15_forces(:,1), yawM10_forces(:,1), yawM5_forces(:,1), yaw0_forces(:,1), yaw5_forces(:,1), yaw10_forces(:,1), yaw15_forces(:,1)]
%convert balance forces to aircraft forces
Xa_all=fx_all*(-1)
Ya_all=fy_all
Za_all=fz_all*(-1)
%get aerodynamic forces from aircraft force
D2=[((-Xa_all).*cos(beta_all).*cos(alpha_all))-((Ya_all).*sin(beta_all))-((Za_all).*cos(beta_all).*sin(alpha_all))]
S2=[((Xa_all).*sin(beta_all).*cos(alpha_all))-((Ya_all).*cos(beta_all))+((Za_all).*sin(beta_all).*sin(alpha_all))]
L2=[((Xa_all).*sin(alpha_all))-((Za_all).*cos(alpha_all))]
%get aerodynamic coefficients
q_inf2 = [yawM5(2:12,3), yawM10(2:12,3), yawM15(2:12,3), yaw0(2:12,3), yaw5(2:12,3), yaw10(2:12,3), yaw15(2:12,3)]
A = 0.4;
CD2 = D2./(q_inf2.*A)
CS2 = S2./(q_inf2.*A)
CL2 = (L2./(q_inf2.*A))
%make meaningful plots
%plot i was getting was linear
% create new alpha array with more data points
%create parabolic lift vs AoA graph
%create vector for aoa so ut can be plotted then fit data to parabola
CL_mean = mean(CL2, 2);
alpha_vec = [-15 -10 -7.5 -5 -2.5 0 2.5 5 7.5 10 15];
p = polyfit(alpha_vec, CL_mean, 1);
alpha_plot = linspace(-15, 15, 1000);
CL_parabola = polyval(p, alpha_plot);
figure;
plot(alpha_plot, CL_parabola);
xlabel('Angle of Attack (degrees)');
ylabel('Lift Coefficient (CL)');
title('Linear Fit of Lift Coefficient vs Angle of Attack');
drawnow;
saveas(gcf, 'figure.png')
  1 Comment
Walter Roberson
Walter Roberson on 26 Mar 2023
We do not have your data files to test with.
After the code has run, show us the result of
nnz(~isfinite(CL_parabola))

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!