trying to plot 3 variables in 3d
조회 수: 1 (최근 30일)
이전 댓글 표시
clc
clear all
theta= linspace(.01, .55) %for thetamax = 32 degrees
M=linspace(2,5)
gamma=1.4
lambda3=sqrt((((M.^2)-1).^2)-3.*(1+((gamma-1)/2).*(M.^2)).*(1+((gamma+1)/2).*(M.^2)).*(tan(theta)).^2);
chi=(1./(lambda3.^3)).*((((M.^2)-1).^3)-9.*(1+((gamma-1)./2).*(M.^2)).*(1+((gamma-1)/2).*(M.^2)+((gamma+1)./4).*(M.^4)).*((tan(theta)).^2));
beta= atan(((M.^2)-1+2.*lambda3.*cos((4.*pi+acos(chi))./3))./(3.*(1+((gamma-1)/2).*(M.^2)).*tan(theta)))
M1n=M.*sin(beta)
strength=1+((2*gamma)/(gamma+1)).*((M1n.^2) -1)
figure
surf(M, beta,strength)
im trying to 3d plot strength vs M and beta but it keeps saying strength isnt a matrix.
댓글 수: 0
채택된 답변
Davide Masiello
2022년 11월 2일
편집: Davide Masiello
2022년 11월 2일
surf can handle only matrices, so this is what you want to do
theta= linspace(.01, .55); %for thetamax = 32 degrees
M=linspace(2,5);
gamma=1.4;
lambda3=sqrt((((M.^2)-1).^2)-3.*(1+((gamma-1)/2).*(M.^2)).*(1+((gamma+1)/2).*(M.^2)).*(tan(theta)).^2);
chi=(1./(lambda3.^3)).*((((M.^2)-1).^3)-9.*(1+((gamma-1)./2).*(M.^2)).*(1+((gamma-1)/2).*(M.^2)+((gamma+1)./4).*(M.^4)).*((tan(theta)).^2));
beta= atan(((M.^2)-1+2.*lambda3.*cos((4.*pi+acos(chi))./3))./(3.*(1+((gamma-1)/2).*(M.^2)).*tan(theta)));
[M,beta] = meshgrid(M,beta);
M1n=M.*sin(beta);
strength=1+((2*gamma)/(gamma+1)).*((M1n.^2) -1)
figure
surf(M, beta,strength)
댓글 수: 0
추가 답변 (1개)
Voss
2022년 11월 2일
clc
clear all
theta= linspace(.01, .55); %for thetamax = 32 degrees
M=linspace(2,5);
gamma=1.4;
lambda3=sqrt((((M.^2)-1).^2)-3.*(1+((gamma-1)/2).*(M.^2)).*(1+((gamma+1)/2).*(M.^2)).*(tan(theta)).^2);
chi=(1./(lambda3.^3)).*((((M.^2)-1).^3)-9.*(1+((gamma-1)./2).*(M.^2)).*(1+((gamma-1)/2).*(M.^2)+((gamma+1)./4).*(M.^4)).*((tan(theta)).^2));
beta= atan(((M.^2)-1+2.*lambda3.*cos((4.*pi+acos(chi))./3))./(3.*(1+((gamma-1)/2).*(M.^2)).*tan(theta)));
% transpose beta to get the appropriate matrix M1n:
M1n=M.*sin(beta.')
strength=1+((2*gamma)/(gamma+1)).*((M1n.^2) -1);
figure
surf(M, beta,strength)
xlabel('M')
ylabel('beta')
zlabel('strength')
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!