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

4 Ansichten (letzte 30 Tage)
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 Kommentar
VBBV
VBBV am 5 Mai 2023
Verschoben: VBBV am 5 Mai 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])

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

VBBV
VBBV am 5 Mai 2023
Bearbeitet: VBBV am 5 Mai 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 Kommentare
Dean
Dean am 5 Mai 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 am 5 Mai 2023
Bearbeitet: VBBV am 5 Mai 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])

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by