I am trying to plot multiple data sets on one one diagram. When I use the plot function, I am not getting any data plots.
Show older comments
I am a novice to Matlab. My goal for this code is to calculate exit Mach numbers and total pressure ratios using a set of equations. The following code is what I generated based on my knowledge (I am sure there is a better way) but for some reason, I am not getting any data plots. Code:
clc
clear all
M1 = [1:0.1:2.5]; %%Free Stream Mach
a = [-2.5:0.5:2.5]; %%Angles of Attack
gamma = 1.4;
Beta1 = [5 8 12]; %%Design 1
Beta2 = [7 8 10];%%Design 2
Beta3 = [5 10 10];%%Design 3
Beta4 = [8.33 8.33 8.33];%%Design 4
Beta5 = [3 5 17];%%Design 5
%%normal shock relation
for i=1:length(M1)
M2 = sqrt((1+((gamma-1)./2)*(M1(i).^2))./((gamma.*(M1(i).^2))-((gamma-1)./2)))
p2p1 = (1+((2.*gamma)./(gamma+1))*((M1(i).^2)-1))
p02p2 = (1+((gamma-1)./2).*M2.^2).^(gamma./(gamma-1))
p1p01 = (1+((gamma-1)./2).*M1(i).^2).^-(gamma./(gamma-1))
p02p01 = (p2p1).*(p02p2).*(p1p01)
hold on
end
%%Oblique shock relation
for i=1:length(M1)
for j=1:length(Beta1)
theta1 = atand(2.*cotd(Beta1(j)).*((((M1(i).^2).*(sin(Beta1(j))).^2)-1)./((M1(i).^2).*(gamma+cos(2.*Beta1(j)))+2)))
Mn1 = M1(i).*sind(Beta1(j));
Mn2 = sqrt((Mn1.^2)+(2./(gamma-1))./(((2.*gamma)./(gamma-1)).*(Mn1.^2)-1));
M2 = Mn2./(sind(Beta1(j)-theta1));
p2p1 = (1+((2.*gamma)./(gamma+1)).*((Mn1.^2)-1))
p02p2 = (1+((gamma-1)./2).*Mn2.^2).^(gamma./(gamma-1))
p1p01 = (1+((gamma-1)./2).*Mn1.^2).^-(gamma./(gamma-1))
p02p01 = (p2p1).*(p02p2).*(p1p01)
hold on
end
for j=1:length(Beta2)
theta2 = atand(2.*cotd(Beta2(j)).*((((M1(i).^2).*(sin(Beta2(j))).^2)-1)./((M1(i).^2).*(gamma+cos(2.*Beta2(j)))+2)))
Mn1 = M1(i).*sind(Beta2(j));
Mn2 = sqrt((Mn1.^2)+(2./(gamma-1))./(((2.*gamma)./(gamma-1)).*(Mn1.^2)-1));
M2 = Mn2./(sind(Beta2(j)-theta2));
p2p1 = (1+((2.*gamma)./(gamma+1)).*((Mn1.^2)-1))
p02p2 = (1+((gamma-1)./2).*Mn2.^2).^(gamma./(gamma-1))
p1p01 = (1+((gamma-1)./2).*Mn1.^2).^-(gamma./(gamma-1))
p02p01 = (p2p1).*(p02p2).*(p1p01)
hold on
end
for j=1:length(Beta3)
theta3 = atand(2.*cotd(Beta3(j)).*((((M1(i).^2).*(sin(Beta3(j))).^2)-1)./((M1(i).^2).*(gamma+cos(2.*Beta3(j)))+2)))
Mn1 = M1(i).*sind(Beta3(j));
Mn2 = sqrt((Mn1.^2)+(2./(gamma-1))./(((2.*gamma)./(gamma-1)).*(Mn1.^2)-1));
M2 = Mn2./(sind(Beta3(j)-theta3));
p2p1 = (1+((2.*gamma)./(gamma+1)).*((Mn1.^2)-1))
p02p2 = (1+((gamma-1)./2).*Mn2.^2).^(gamma./(gamma-1))
p1p01 = (1+((gamma-1)./2).*Mn1.^2).^-(gamma./(gamma-1))
p02p01 = (p2p1).*(p02p2).*(p1p01)
hold on
end
for j=1:length(Beta4)
theta4 = atand(2.*cotd(Beta4(j)).*((((M1(i).^2).*(sin(Beta4(j))).^2)-1)./((M1(i).^2).*(gamma+cos(2.*Beta4(j)))+2)))
Mn1 = M1(i).*sind(Beta4(j));
Mn2 = sqrt((Mn1.^2)+(2./(gamma-1))./(((2.*gamma)./(gamma-1)).*(Mn1.^2)-1));
M2 = Mn2./(sind(Beta4(j)-theta4));
p2p1 = (1+((2.*gamma)./(gamma+1)).*((Mn1.^2)-1))
p02p2 = (1+((gamma-1)./2).*Mn2.^2).^(gamma./(gamma-1))
p1p01 = (1+((gamma-1)./2).*Mn1.^2).^-(gamma./(gamma-1))
p02p01 = (p2p1).*(p02p2).*(p1p01)
hold on
end
for j=1:length(Beta5)
theta5 = atand(2.*cotd(Beta5(j))*((((M1(i).^2).*(sin(Beta5(j))).^2)-1)./((M1(i).^2).*(gamma+cos(2.*Beta5(j)))+2)))
Mn1 = M1(i).*sind(Beta5(j));
Mn2 = sqrt((Mn1.^2)+(2./(gamma-1))./(((2.*gamma)./(gamma-1)).*(Mn1.^2)-1));
M2 = Mn2./(sind(Beta5(j)-theta5));
p2p1 = (1+((2.*gamma)./(gamma+1)).*((Mn1.^2)-1))
p02p2 = (1+((gamma-1)./2).*Mn2.^2).^(gamma./(gamma-1))
p1p01 = (1+((gamma-1)./2).*Mn1.^2).^-(gamma./(gamma-1))
p02p01 = (p2p1).*(p02p2).*(p1p01)
hold on
end
end
plot(M1,p02p01, 'LineWidth', 4);
Accepted Answer
More Answers (0)
Categories
Find more on Geographic Plots 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!
