plotting 3D surface grids

11 vues (au cours des 30 derniers jours)
R shah
R shah le 30 Juil 2016
Commenté : Star Strider le 30 Juil 2016
what specification should i use in order to get this sort (colour) of surf (X, Y, Z) grid attached below?

Réponse acceptée

Star Strider
Star Strider le 30 Juil 2016
This will reproduce it:
x = -40:5:40;
y = ones(1,16);
[X,Y] = meshgrid(x,y);
z = @(x,y) bsxfun(@plus, tanh(x * 0.1).*0.1, 1.5*Y);
Z = z(X,Y);
figure(1)
mesh(Z)
grid on
qx = xlim;
axis([1 17 1 16 1.4 max(zlim)])
view([25 60])
xt = 1:4:length(x);
xtl = regexp(sprintf('%.0f ',linspace(-40, 40, length(xt))), ' ', 'split');
set(gca, 'XTick',xt, 'XTickLabel',xtl(1:end-1))
yt = 1:5:length(y);
ytl = regexp(sprintf('%.0f ',linspace(0, 4, length(yt))), ' ', 'split');
set(gca, 'YTick',yt, 'YTickLabel',ytl(1:end-1))
zt = linspace(1.40, 1.60, 5);
ztl = regexp(sprintf('%.2f ',zt), ' ', 'split');
set(gca, 'ZTick',zt, 'ZTickLabel',ztl(1:end-1))
yielding this plot:
Reproducing it exactly without knowing the code that created the original means that this code is not as efficient as I would like it to be. Nevertheless, it works.
  2 commentaires
R shah
R shah le 30 Juil 2016
Modifié(e) : Star Strider le 30 Juil 2016
I want the above mesh for the given below data can u help me in this regard as i'm not getting the exact scale for X and T in mesh:
x = [-1, -0.973, -0.911, -0.816, -0.691, -0.541, -0.372, -0.190, 0, 0.190, 0.372, 0.541, 0.691, 0.816, 0.911, 0.973, 1];
t = (0.01:0.01:0.1);
[X,T] = meshgrid(x,t);
Z = [1.4902 1.4904 1.4911 1.4920 1.4933 1.4947 1.4964 1.4983 1.5001 1.5020 1.5039 1.5056 1.5070 1.5083 1.5092 1.5098 1.5101;
1.4903 1.4906 1.4912 1.4922 1.4934 1.4949 1.4966 1.4984 1.5003 1.5022 1.5040 1.5057 1.5072 1.5084 1.5094 1.5100 1.5103;
1.4905 1.4907 1.4914 1.4923 1.4935 1.4950 1.4967 1.4986 1.5004 1.5023 1.5042 1.5059 1.5073 1.5086 1.5095 1.5101 1.5104;
1.4906 1.4909 1.4915 1.4925 1.4937 1.4952 1.4969 1.4987 1.5006 1.5025 1.5043 1.5060 1.5075 1.5087 1.5097 1.5103 1.5106;
1.4908 1.4910 1.4917 1.4926 1.4938 1.4953 1.4970 1.4989 1.5007 1.5026 1.5045 1.5062 1.5076 1.5089 1.5098 1.5104 1.5107;
1.4909 1.4912 1.4918 1.4928 1.4940 1.4955 1.4972 1.4990 1.5009 1.5028 1.5046 1.5063 1.5078 1.5090 1.5100 1.5106 1.5109;
1.4911 1.4913 1.4920 1.4929 1.4941 1.4956 1.4973 1.4992 1.5010 1.5029 1.5048 1.5065 1.5079 1.5092 1.5101 1.5107 1.5110;
1.4912 1.4915 1.4921 1.4931 1.4943 1.4958 1.4975 1.4993 1.5012 1.5031 1.5049 1.5066 1.5081 1.5093 1.5103 1.5109 1.5112;
1.4914 1.4916 1.4923 1.4932 1.4944 1.4959 1.4976 1.4995 1.5013 1.5032 1.5051 1.5067 1.5082 1.5095 1.5104 1.5110 1.5113;
1.4915 1.4918 1.4924 1.4933 1.4946 1.4961 1.4978 1.4996 1.5015 1.5034 1.5052 1.5069 1.5084 1.5096 1.5106 1.5112 1.5114];
mesh(Z)
xlabel('x'); ylabel('t')
zlabel(' z3 (x, t)')
Star Strider
Star Strider le 30 Juil 2016
For the axis scales to display correctly, use both mesh independent coordinates arguments in the mesh call:
mesh(X,T,Z)
That should do what you want.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by