Visualization of a scalar field in a solid
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] and the scalar field [math] f(x,y)=-\log (0.1+\sqrt{x^2+y^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 coordinates 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
{{matlab|codigo= % --- Mallado del arco --- theta = linspace(0, pi, 200); % más denso para curva suave r = linspace(1, 2, 200); % radio interior 1, exterior 2 [R, TH] = meshgrid(r, theta);
% Convertir a cartesianas X = R .* cos(TH); Y = R .* sin(TH);
% --- Temperatura --- T = (X - Y).^2;
% --- Representación 2D --- figure; pcolor(X, Y, T); % representación 2D en colores shading interp % suavizado del color colormap(jet) colorbar;
title('Temperatura T(x,y) = (x - y)^2 sobre el arco') xlabel('x') ylabel('y') axis equal % mantiene proporciones reales
2 To go further
Mesh of a parametrized 2-D solid