I wish to limit plotting a point on a single line and not anywhere else on the graph (just on the line) with every input

1 view (last 30 days)
for M1 = 1:1:5
m = m+1;
%================================
% theta-beta-M relation
%================================
Nr = ((M1^2)*((sin(beta_range)).^2))-1;
Dr = ((gamma+(cos(2*beta_range)))*M1^2)+2;
theta = atan(2*cot(beta_range).*Nr./Dr);
%================================
% max. theta for a M1
%================================
% For a given mach number, theta max flow deflection angle for which an
% attached shock is possible.
% max theta for the Mach No.
a(m) = max(theta);
% find the beta for max. theta
b(m) = beta_range(find(theta==a(m)));
plot(theta,beta_range,'-b')
hold on
end
% Mach number downstream of a strong shock will always be sub-sonic
plot(a,b,'-r','Linewidth',1.5)
xlabel('\theta')
ylabel('\beta')
axis([0 42*pi/180 0 pi/2])
% Flow Deflection angle theta Comes from geometry in radian
Theta_r1 = 0.261;
% Flow Deflection angle in degrees
for M1 = 5
Theta_1 = Theta_r1*(180/pi);
fprintf('Flow Deflection angle = %0.2f°\n', Theta_1);
end
% Shock wave angle in radians
beta_r1 = interp1(theta,beta_range,Theta_r1)
% Shock wave angle in radians
Beta_1 = beta_r1*(180/pi);
fprintf('Shock wave angle = %0.2f°\n', Beta_1);
if Theta_r1 < a(m)
fprintf('Weak Shock wave')
else
fprintf('Strong Shock wave')
end
plot (Theta_r1,beta_r1, 'o')
%This is a standard Theta-Beta-Mach Number plot
%The plot this code will generated will have 4 curved lines. Each represents Mach number M1. Outermost being Mach 5. With every input value of theta_r1, I wish to limit plotting the point only on Mach 5 line.
Thanks in advance.
  1 Comment
VBBV
VBBV on 5 May 2023
Moved: VBBV on 5 May 2023
It seems you are converting the Theta and Beta values to degrees which produces out of bound values of the chart and makes it invisible.
m = 0;
% change these range values for different curve
beta_range = linspace(0,pi/2,100);
gamma = 1.4;
for M1 = 1:1:5
m = m+1;
%================================
% theta-beta-M relation
%================================
Nr = ((M1^2)*((sin(beta_range)).^2))-1;
Dr = ((gamma+(cos(2*beta_range)))*M1^2)+2;
theta = atan(2*cot(beta_range).*Nr./Dr);
%================================
% max. theta for a M1
%================================
% For a given mach number, theta max flow deflection angle for which an
% attached shock is possible.
% max theta for the Mach No.
a(m) = max(theta);
% find the beta for max. theta
b(m) = beta_range(find(theta==a(m)));
plot(theta,beta_range,'-b')
hold on
end
xlabel('\theta')
ylabel('\beta')
axis([0 42*pi/180 0 pi/2])
% Mach number downstream of a strong shock will always be sub-sonic
plot(a,b,'-r','Linewidth',1.5)
hold on
% Flow Deflection angle theta Comes from geometry in radian
Theta_r1 = 0.261;
% Flow Deflection angle in degrees
if isequal(M1, 5)
Theta_1 = Theta_r1;
fprintf('Flow Deflection angle = %0.2f°\n', Theta_1);
% Shock wave angle in radians
beta_r1 = interp1(theta,beta_range,Theta_r1)
% Shock wave angle in radians
Beta_1 = beta_r1;
fprintf('Shock wave angle = %0.2f°\n', Beta_1);
if Theta_r1 < max(a)
fprintf('Weak Shock wave')
else
fprintf('Strong Shock wave')
end
% put this line insdie the condition for Mach number = 5
plot (Theta_r1,Beta_1, 'ro','MarkerFaceColor','r')
end
Flow Deflection angle = 0.26°
beta_r1 = 0.4237
Shock wave angle = 0.42°
Weak Shock wave
xlim([0 pi/4]); ylim([0 pi/2])

Sign in to comment.

Accepted Answer

VBBV
VBBV on 5 May 2023
Edited: VBBV on 5 May 2023
for M1 = 1:1:5
m = m+1;
%================================
% theta-beta-M relation
%================================
Nr = ((M1^2)*((sin(beta_range)).^2))-1;
Dr = ((gamma+(cos(2*beta_range)))*M1^2)+2;
theta = atan(2*cot(beta_range).*Nr./Dr);
%================================
% max. theta for a M1
%================================
% For a given mach number, theta max flow deflection angle for which an
% attached shock is possible.
% max theta for the Mach No.
a(m) = max(theta);
% find the beta for max. theta
b(m) = beta_range(find(theta==a(m)));
plot(theta,beta_range,'-b')
hold on
end
% Mach number downstream of a strong shock will always be sub-sonic
plot(a,b,'-r','Linewidth',1.5)
xlabel('\theta')
ylabel('\beta')
axis([0 42*pi/180 0 pi/2])
% Flow Deflection angle theta Comes from geometry in radian
Theta_r1 = 0.261;
% Flow Deflection angle in degrees
hold on
if isequal(M1, 5)
Theta_1 = Theta_r1*(180/pi);
fprintf('Flow Deflection angle = %0.2f°\n', Theta_1);
% Shock wave angle in radians
beta_r1 = interp1(theta,beta_range,Theta_r1)
% Shock wave angle in radians
Beta_1 = beta_r1*(180/pi);
fprintf('Shock wave angle = %0.2f°\n', Beta_1);
if Theta_r1 < a(m)
fprintf('Weak Shock wave')
else
fprintf('Strong Shock wave')
end
% put this line insdie the condition for Mach number = 5
plot (Theta_1,Beta_1, 'o')
end
put this line insdie the condition for Mach number = 5
plot (Theta_r1,beta_r1, 'o')
  2 Comments
Dean
Dean on 5 May 2023
I used your input but it did not work. May I did not explain it better. Allow me to try again, this is the figure that my code generates, has a red line line that connects all the maximum theta values for each mach number. For mach 5 (outermost curve). When I input the the of certain theta angle. I want matlab to plot a point below the maximum theta angle line for output of the corresonding beta value suggesting a weak shock wave. Everything about the red line gives a strong shock wave.
VBBV
VBBV on 5 May 2023
Edited: VBBV on 5 May 2023
It will plot exactly on the outer curve if you use the code which i gave earlier, See the example demonstration below plotted not for a maximum theta angle
m = 0;
% change these range values for different curve
beta_range = linspace(0,pi/2,100);
gamma = 1.4;
for M1 = 1:1:5
m = m+1;
%================================
% theta-beta-M relation
%================================
Nr = ((M1^2)*((sin(beta_range)).^2))-1;
Dr = ((gamma+(cos(2*beta_range)))*M1^2)+2;
theta = atan(2*cot(beta_range).*Nr./Dr);
%================================
% max. theta for a M1
%================================
% For a given mach number, theta max flow deflection angle for which an
% attached shock is possible.
% max theta for the Mach No.
a(m) = max(theta);
% find the beta for max. theta
b(m) = beta_range(find(theta==a(m)));
plot(theta,beta_range,'-b')
hold on
end
xlabel('\theta')
ylabel('\beta')
axis([0 42*pi/180 0 pi/2])
% Mach number downstream of a strong shock will always be sub-sonic
%plot(a,b,'-r','Linewidth',1.5)
hold on
% Flow Deflection angle theta Comes from geometry in radian
Theta_r1 = 0.161;
% Flow Deflection angle in degrees
if isequal(M1, 5)
Theta_1 = Theta_r1;
fprintf('Flow Deflection angle = %0.2f°\n', Theta_1);
% Shock wave angle in radians
beta_r1 = interp1(theta,beta_range,Theta_r1)
% Shock wave angle in radians
Beta_1 = beta_r1;
fprintf('Shock wave angle = %0.2f°\n', Beta_1);
if Theta_r1 < max(a)
fprintf('Weak Shock wave')
else
fprintf('Strong Shock wave')
end
% put this line insdie the condition for Mach number = 5
plot (Theta_r1,Beta_1, 'ro','MarkerFaceColor','r')
end
Flow Deflection angle = 0.16°
beta_r1 = 0.3258
Shock wave angle = 0.33°
Weak Shock wave
xlim([0 pi/4]); ylim([0 pi/2])

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!