Superimposing two 3 D surface plots
Mostrar comentarios más antiguos
I have multiple surface plots written using surf or mesh command. I now want to plot two or more surface plots in the same figure in order to show the difference between the two. For 2-D plots, its very straightforward. But I am unable to do so for 3D plots. Kindly help. I have given a sample code where u or U represents the two outputs to be plotted on the z- axis and x1 and x2 are the two input variables to be plotted on the x and y axes.Although u and U are different, the difference is not visible on the plot.
clc
clear all
close all
%tic
range=1;
resolution=0.1;
x1=-range:resolution:range;
x2=-range:resolution:range;
k=(range/resolution)*2+1;
h=1;
h1=1;
H=2;
H1=2;
A=1;
B=2;
for i=1:k;
for j=1:k;
if (x1(i)>=-h) && (x1(i)<=h) && (x2(j)>=-h1) && (x2(j)<=h1)
u(i,j)=-((2*A^2+5*A*B+2*B^2)*(x2(j)*h+x1(i)*h1))/(3*(A+B)*(x1(i)*x2(j)-3*h*h1));
else
u(i,j)=0;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for q=1:k
for j=1:k
if (x1(q)>=-h) && (x1(q)<=h) && (x2(j)>=-h1) && (x2(j)<=h1)&& x2(j)<=(h1/h)*x1(q)
U(q,j)=-((x2(j)*h + x1(q)*h1)*((A - B)^2*x2(j)^2*(3*x1(q)^2 + h^2) -8*(A - B)*(2*A + B)*x2(j)*x1(q)*h*h1+((A - B)^2*x1(q)^2 - 3*(A + 3*B)*(7*A + 5*B)*h^2)*h1^2))/(24*h*h1*((A - B)*x2(j)^2*(x1(q)^2 + x1(q)*h + h^2)-x2(j)*((A - B)*x1(q)^2 + (A + 3*B)*h^2)*h1 +((A - B)*x1(q)^2 + (A + 3*B)*x1(q)*h + (A + 7*B)*h^2)*h1^2));
elseif (x1(q)>=-h) && (x1(q)<=h) && (x2(j)>=-h1) && (x2(j)<=h1)&& x2(j)>=(h1/h)*x1(q)
U(q,j)=-((x2(j)* h + x1(q)*h1)*((A - B)^2*x2(j)^2*(3*x1(q)^2 + h^2)-8*(A - B)*(2*A + B)*x2(j)*x1(q)*h*h1+((A - B)^2*x1(q)^2 - 3*(A + 3*B)*(7*A + 5*B)*h^2)*h1^2))/(24*h*h1*((A - B)*x2(j)^2*(x1(q)^2 - x1(q)*h + h^2)+x2(j)*((A - B)*x1(q)^2 + (A + 3*B)*h^2)*h1+((A - B)*x1(q)^2 - (A + 3*B)*x1(q)*h + (A + 7*B)*h^2)*h1^2));
else
U(q,j)=0;
end
end
end
% sUrf(x1,x2,U')
%mesh(x1,x2,U')
%Y14=u'-U';
mesh(x1,x2,u')
hold on
mesh(x1,x2,U')
xlabel('x1'), ylabel('x2'),zlabel('u or U')
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
