How do I plot a diagonal line in MATLAB?

161 views (last 30 days)
I am creating a V-n diagram in matlab. I wrote the code to solve the given equations but for the sake of time, I am connecting all of the given points with straight solid or dashed lines. Until now, the lines only needed to be vertical or horizontal but I need to now plot gust load lines and I am not sure how to plot this.
I do know there are a couple of apps that plot the V-n diagram for me but I am trying to create this V-n diagram on my own. I will also say that I am very novice with MATLAB so my knowledge of short cuts or hidden functions is almost non-existent.
Any help would be greatly appreciated! Thanks!
My current code:
clc
clear all
%%Given Parameters for a GA Acrobatic Aircraft
M = 2300
S = 19.33
C_Lmax = 2
C_Lmaxneg = -1.2
AR = 7
C_lalpha = 6.31
V_c = 310*0.514444 %%Cruise speed (Knots converted to m/s)
U_de1 = 50*0.3048
U_de2 = 25*0.3048
%%FAR23 Load Limit Factors
n_pos = 6
n_neg = 0.5*n_pos
rho = 0.4135 %%Density of air at 10k feet
g = 9.81 %%Gravitational Constant
b = sqrt(AR*S) %%wing span
%%Load, n
n = [1]
nneg = [-1]
n_pos = [0:0.1:6]
n_neg = [0:-0.1:-3]
%%Maximum normal force coefficient (postive,negative)
C_Npos = 1.1*C_Lmax
C_Nneg = 1.1*C_Lmaxneg
%Stall speed calculations
V_Sn = sqrt((2*M*g*n_pos)/(rho*C_Npos*S))%%Range of stall speeds for a range of loads
V_Snneg = sqrt((2*M*g*abs(nneg))/(rho*abs(C_Nneg)*S))
%%1-g stall speed, V_s
V_S = sqrt((2*M*g)/(rho*C_Npos*S))%%1-g load stall speed
%%Design maneuvering speed, V_A
V_A = V_S*sqrt(6)
%%Design diving speed, V_D
V_D = 1.25*V_c
%%Negative 1-g stall speed, V_Sneg
V_Sneg = sqrt((2*M*g*abs(n_neg))/(rho*abs(C_Nneg)*S))
%Calculation of gust lines
b = sqrt(AR*S)
c = (0.4244*b)/2
mu_g = (2*((M*g)/S))/(rho*g*C_lalpha*c)
K_g = (0.88*mu_g)/(5.3+mu_g)
%V_C gust lines
n_lim1 = 1+((K_g*U_de1*V_c*C_lalpha)/(498*((M*g)/S)))
n_lim2 = 1-((K_g*U_de1*V_c*C_lalpha)/(498*((M*g)/S)))
%V_D gust lines
n_lim3 = 1+((K_g*U_de2*V_c*C_lalpha)/(498*((M*g)/S)))
n_lim4 = 1-((K_g*U_de2*V_c*C_lalpha)/(498*((M*g)/S)))
plot(V_Sn,n_pos)
hold on
plot(V_S,n,'o')
plot(V_A,n_pos,'|')
plot(V_D,n_pos,'|')
plot(V_Snneg,nneg,'o')
plot(V_Sneg,n_neg)
yline(0,'-');
plot(n_lim1,'-')
plot(n_lim2,'-')
plot(n_lim3,'-')
plot(n_lim4,'-')
line([65.3993,65.3993],[0,-1]);
line([50.6580,50.6580],[0,1]);
line([124.0864,199.3471],[6,6]);
line([199.3471,199.3471],[6,-3]);
line([113.2748,199.3471],[-3,-3]);
hold off
xlabel('Velocity (m/s)')
ylabel('Load Factor, n')
title('V-n Diagram')
  1 Comment
dpb
dpb on 13 Oct 2022
hL=plot([0 1],[0 1],'DisplayName','Diagonal'); % 45 on default axis
legend
figure
hL=plot([0 1],[0 1],'DisplayName','Square Aspect Ratio'); % 45 line visible at 45
legend
axis('square')

Sign in to comment.

Accepted Answer

VBBV
VBBV on 22 Oct 2022
Edited: VBBV on 22 Oct 2022
clc
clear all
%%Given Parameters for a GA Acrobatic Aircraft
M = 2300;
S = 19.33;
C_Lmax = 2;
C_Lmaxneg = -1.2;
AR = 7;
C_lalpha = 6.31;
V_c = 310*0.514444;%%Cruise speed (Knots converted to m/s)
U_de1 = 50*0.3048;
U_de2 = 25*0.3048;
%%FAR23 Load Limit Factors
n_pos = 6;
n_neg = 0.5*n_pos;
rho = 0.4135; %%Density of air at 10k feet
g = 9.81 ;%%Gravitational Constant
b = sqrt(AR*S); %%wing span
%%Load, n
n = [1];
nneg = [-1];
n_pos = [0:0.1:6];
n_neg = [0:-0.1:-3];
%%Maximum normal force coefficient (postive,negative)
C_Npos = 1.1*C_Lmax;
C_Nneg = 1.1*C_Lmaxneg;
%Stall speed calculations
V_Sn = sqrt((2*M*g*n_pos)/(rho*C_Npos*S));%%Range of stall speeds for a range of loads
V_Snneg = sqrt((2*M*g*abs(nneg))/(rho*abs(C_Nneg)*S));
%%1-g stall speed, V_s
V_S = sqrt((2*M*g)/(rho*C_Npos*S));%%1-g load stall speed
%%Design maneuvering speed, V_A
V_A = V_S*sqrt(6);
%%Design diving speed, V_D
V_D = 1.25*V_c;
%%Negative 1-g stall speed, V_Sneg
V_Sneg = sqrt((2*M*g*abs(n_neg))/(rho*abs(C_Nneg)*S));
%Calculation of gust lines
b = sqrt(AR*S);
c = (0.4244*b)/2;
mu_g = (2*((M*g)/S))/(rho*g*C_lalpha*c);
K_g = (0.88*mu_g)/(5.3+mu_g);
%V_C gust lines
n_lim1 = 1+((K_g*U_de1*V_c*C_lalpha)/(498*((M*g)/S)));
n_lim2 = 1-((K_g*U_de1*V_c*C_lalpha)/(498*((M*g)/S)));
%V_D gust lines
n_lim3 = 1+((K_g*U_de2*V_c*C_lalpha)/(498*((M*g)/S)));
n_lim4 = 1-((K_g*U_de2*V_c*C_lalpha)/(498*((M*g)/S)));
% plot(V_Sn,n_pos)
% hold on
% plot(V_S,n,'o')
% plot(V_A,n_pos,'|')
% plot(V_D,n_pos,'|')
% plot(V_Snneg,nneg,'o')
% plot(V_Sneg,n_neg)
% yline(0,'-');
% figure
subplot(211)
plot([n_lim1 ;n_lim3],'-')
subplot(212)
plot([n_lim2;n_lim4],'-')
If you want to plot diagonal lines for gust load lines, you can form vector using gust load variables
  1 Comment
Jeffrey Lewis
Jeffrey Lewis on 24 Oct 2022
This method makes sense but when I use these vector plots, I cannot get them to show up on my plot. When I create the subplots as you have done, they show up fine. I want it to be overlayed on the plot already in place. Do you have any tips to adjust this?
clc
clear all
%%Given Parameters for a GA Acrobatic Aircraft
M = 2300
S = 19.33
C_Lmax = 2
C_Lmaxneg = -1.2
AR = 7
C_lalpha = 6.31
V_c = 310*0.514444 %%Cruise speed (Knots converted to m/s)
U_de1 = 50*0.3048
U_de2 = 25*0.3048
%%FAR23 Load Limit Factors
n_pos = 6
n_neg = 0.5*n_pos
rho = 0.4135 %%Density of air at 10k feet
g = 9.81 %%Gravitational Constant
b = sqrt(AR*S) %%wing span
%%Load, n
n = [1]
nneg = [-1]
n_pos = [0:0.1:6]
n_neg = [0:-0.1:-3]
%%Maximum normal force coefficient (postive,negative)
C_Npos = 1.1*C_Lmax
C_Nneg = 1.1*C_Lmaxneg
%Stall speed calculations
V_Sn = sqrt((2*M*g*n_pos)/(rho*C_Npos*S))%%Range of stall speeds for a range of loads
V_Snneg = sqrt((2*M*g*abs(nneg))/(rho*abs(C_Nneg)*S))
%%1-g stall speed, V_s
V_S = sqrt((2*M*g)/(rho*C_Npos*S))%%1-g load stall speed
%%Design maneuvering speed, V_A
V_A = V_S*sqrt(6)
%%Design diving speed, V_D
V_D = 1.25*V_c
%%Negative 1-g stall speed, V_Sneg
V_Sneg = sqrt((2*M*g*abs(n_neg))/(rho*abs(C_Nneg)*S))
%Calculation of gust lines
b = sqrt(AR*S)
c = (0.4244*b)/2
mu_g = (2*((M*g)/S))/(rho*g*C_lalpha*c)
K_g = (0.88*mu_g)/(5.3+mu_g)
%V_C gust lines
n_lim1 = 1+((K_g*U_de1*V_c*C_lalpha)/(498*((M*g)/S)))
n_lim2 = 1-((K_g*U_de1*V_c*C_lalpha)/(498*((M*g)/S)))
%V_D gust lines
n_lim3 = 1+((K_g*U_de2*V_c*C_lalpha)/(498*((M*g)/S)))
n_lim4 = 1-((K_g*U_de2*V_c*C_lalpha)/(498*((M*g)/S)))
plot(V_Sn,n_pos)
hold on
plot(V_S,n,'o')
plot(V_A,n_pos,'|')
plot(V_D,n_pos,'|')
plot(V_Snneg,nneg,'o')
plot(V_Sneg,n_neg)
plot([n_lim2,n_lim4],'-')
plot([n_lim1,n_lim3],'-')
yline(0,'-');
line([65.3993,65.3993],[0,-1]);
line([50.6580,50.6580],[0,1]);
line([124.0864,199.3471],[6,6]);
line([199.3471,199.3471],[6,-3]);
line([113.2748,199.3471],[-3,-3]);
hold off
xlabel('Velocity (m/s)')
ylabel('Load Factor, n')
title('V-n Diagram')

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!