Clase 3 de Leng de Program
-
Upload
jorgepg012 -
Category
Documents
-
view
215 -
download
0
description
Transcript of Clase 3 de Leng de Program
![Page 1: Clase 3 de Leng de Program](https://reader036.fdocuments.co/reader036/viewer/2022081813/55cf92c4550346f57b996d4b/html5/thumbnails/1.jpg)
CLASE Nro. 03 DE LENGUAJE DE PROGRAMACION
1. GRAFICOS EN 3D:
Para plotear una superficie en el espacio (3D), se requiere de tres pasos:
- Generar la malla, es decir se genera el dominio (comando meshgrid)
- Introducir la funcion que permite el rango de la funcion
- Se plotea el grafico (comando surf)
Ejemplo 1: plotear la superficie 𝑧 = 𝑥2 + 𝑦2
[x,y]=meshgrid(-3:3)
x =
3 -2 -1 0 1 2 3
3 -2 -1 0 1 2 3
3 -2 -1 0 1 2 3
3 -2 -1 0 1 2 3
3 -2 -1 0 1 2 3
3 -2 -1 0 1 2 3
3 -2 -1 0 1 2 3 y =
3 -3 -3 -3 -3 -3 -3
2 -2 -2 -2 -2 -2 -2
1 -1 -1 -1 -1 -1 -1
0 0 0 0 0 0 0
1 1 1 1 1 1 1
2 2 2 2 2 2 2
3 3 3 3 3 3 3
z=x.^2+y.^2;
surf(x,y,z)
Mejorando el grafico con una malla mas fina delta=0.1 [x,y]=meshgrid(-3:0.1:3);
z=x.^2+y.^2;
surf(x,y,z)
-4
-2
0
2
4
-4
-2
0
2
40
5
10
15
20
![Page 2: Clase 3 de Leng de Program](https://reader036.fdocuments.co/reader036/viewer/2022081813/55cf92c4550346f57b996d4b/html5/thumbnails/2.jpg)
Ejemplo 2: Trazar la misma funcion en coordenadas cilindricas Generando la malla en coordenadas
cilindricas:
[r,theta]=meshgrid(0:.1:5,0:pi/40:2*pi);
convirtiendo a coordenadas cartesianas x=r.*cos(theta); y=r.*sin(theta);
Generando la funcion:
z=x.^2+y.^2;surf(x,y,z)
hold on
contour(x,y,z)
colorbar;
ploteando la superficie x=0
for i=1:2:7
x=x+i
end
![Page 3: Clase 3 de Leng de Program](https://reader036.fdocuments.co/reader036/viewer/2022081813/55cf92c4550346f57b996d4b/html5/thumbnails/3.jpg)
x =
0
x =
1
x =
4
x =
9
x =
16