how to calculate for a range of values for different initial conditions
조회 수: 4 (최근 30일)
이전 댓글 표시
function [theta]=theta_beta_M(beta,M,gamma)
% return theta for beta-theta-M relationship for oblique shock
beta=linspace(0,(pi/2),90)
M=[1.25, 2, 6, 10)
gamma= 1.4
%cut off at Mach wave angle
if (beta<=asin(1./M)) theta=0; return; end
theta=atan(2.*cot(beta).*((M.*sin(beta)).^2-1)./(M.^2.*(gamma+cos(2.*beta))+2));
i want to be able to calculate theta values for each value of M for the range of beta.
댓글 수: 0
채택된 답변
Walter Roberson
2022년 11월 29일
function [theta]=theta_beta_M(beta,M,gamma)
% return theta for beta-theta-M relationship for oblique shock
if nargin < 1; beta=linspace(0,(pi/2),90); end
if nargin < 2; M=[1.25, 2, 6, 10); end
if nargin < 3; gamma= 1.4; end
[beta,M] = ndgrid(beta, M);
theta = zeros(size(beta));
%cut off at Mach wave angle
mask = beta > asin(1./M);
theta(mask) = atan(2.*cot(beta(mask)).*((M(mask).*sin(beta(mask))).^2-1)./(M(mask).^2.*(gamma+cos(2.*beta(mask)))+2));
The result will be numel(beta) by numel(M) -- so one column for each different M value.
댓글 수: 0
추가 답변 (1개)
David Hill
2022년 11월 29일
beta=linspace(0,(pi/2),90);
m=[1.25, 2, 6, 10];
[B,M]=meshgrid(beta,m);
gamma= 1.4;
theta=atan(2.*cot(B).*((M.*sin(B)).^2-1)./(M.^2.*(gamma+cos(2.*B))+2));
theta(B<=asin(1./M))=0
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Gas Dynamics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!