Visualization of a scalar field in a solid
De MateWiki
Revisión del 20:03 16 nov 2013 de Carlos Castro (Discusión | contribuciones) (Página creada con «We show how to visualize scalar fields on plane regions, representing solids, with Octave UPM. We focus on the example in Dibujar un sólido 2-D, i.e. the rectangle <ma...»)
We show how to visualize scalar fields on plane regions, representing solids, with Octave UPM. We focus on the example in Dibujar un sólido 2-D, i.e. the rectangle [math] [-1/2,1/2]\times [0,2][/math]. We follow the steps:
- We introduce a sampling of the two segments with a suitable step
- With meshgrid command we define two matrixes with the x and y coordenates of the mesh points
- Compute the scalar field in the grid points.
- We use the surf command to draw the field and adjunst the axis. We see the picture from the top.
1 MATLAB code
f=-log(0.1+sqrt(xx.^2+yy.^2));surf(xx,yy,f)axis([-2,2,-1,3])view([0,0,1])
x=-0.5:0.1:0.5; % sampling of the interval [-1/2,1/2]
y=0:0.1:2; % sampling of the interval [0,2]
[xx,yy]=meshgrid(x,y); % matrixes of x and y coordinates
figure(1)
f=-log(0.1+sqrt(xx.^2+yy.^2)); % The scalar field
surf(xx,yy,f) % Draw the mesh
axis([-2,2,-1,3]) % select region for drawing
view([0,0,1]) % See the pisture from the top