trying to plot 3 variables in 3d
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
joshua payne
le 2 Nov 2022
Réponse apportée : Voss
le 2 Nov 2022
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 commentaires
Réponse acceptée
Davide Masiello
le 2 Nov 2022
Modifié(e) : Davide Masiello
le 2 Nov 2022
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 commentaires
Plus de réponses (1)
Voss
le 2 Nov 2022
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 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!