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!