miércoles, 15 de mayo de 2019

MATLAB 3D



clc;
clear all;
 t = 0:pi/10:2*pi;
[X,Y,Z] = cylinder(4*cos(t));
subplot(3,3,1);
mesh(X);
title('X');
subplot(3,3,2);
mesh(Y);
title('Y');
subplot(3,3,,3);
mesh(Z);
title('Z');
subplot(3,3,4);
mesh(X,Y,Z);
title('X,Y,Z');
 
[X,Y] = meshgrid(-8:.5:8); 
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
subplot(3,3,5);
mesh(X,Y,Z);
title ('sin(R)./R');

x=-2:0.1:2;
y=-3:0.1:3;
[X,Y]=meshgrid(x,y);
Z=X.^2-Y.^2;
subplot(3,3,6);
mesh(X,Y,Z);
xlabel('X');
ylabel('Y');
zlabel('Z');

theta=pi/3;
r=linspace(0,1,30);
phi=linspace(0,2*pi,30);
[r,phi]=meshgrid(r,phi);
x=r.*cos(phi)*sin(theta);
y=r.*sin(phi)*sin(theta);
z=r*cos(theta);
subplot(3,3,7);
mesh(x,y,z)
xlabel('x');
ylabel('y');
zlabel('z');
title('Superficie cónica')

[x,y] = meshgrid(-7:0.25:7);
r = sqrt(x.^2 + y.^2) + eps;
z = sin(r)./r;
subplot(3,3,8);
surf(x,y,z)
colormap hsv
colorbar
xlabel('x');
ylabel('y');
zlabel('z');
x= [-2:0.2:2] ;
y= [-2:0.2:2] ;
[X,Y]=meshgrid(x,y) ;
Z= X.*exp(-X.^2 - Y.^2);
subplot(3,3,9);
mesh(X,Y,Z), figure(gcf);
xlabel ('eje-X');
ylabel ('eje-Y');
zlabel('eje-Z');





No hay comentarios:

Publicar un comentario