trying to plot 3 variables in 3d
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
joshua payne
am 2 Nov. 2022
Beantwortet: Voss
am 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 Kommentare
Akzeptierte Antwort
Davide Masiello
am 2 Nov. 2022
Bearbeitet: Davide Masiello
am 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 Kommentare
Weitere Antworten (1)
Voss
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!