RunMat
GitHub

View all functions

CategoryPlotting

What does surf do?

surf(X, Y, Z) draws a shaded surface where X and Y provide axis coordinates and Z provides heights. RunMat expects X and Y to be vectors defining the grid axes (rows × columns), and Z to contain numel(X) * numel(Y) elements stored in column-major order, matching MATLAB tensors. When Z is a single-precision gpuArray and the shared WebGPU renderer is active, the surface geometry stays on the device and feeds a compute shader that emits renderer-ready vertices.

Behaviour highlights

  • Axis vectors must be non-empty and Z must contain exactly length(X) * length(Y) elements.
  • Single-precision gpuArray height maps stream directly into the renderer; other precisions gather to host memory before plotting.
  • Surfaces default to the Parula colormap with smooth shading and lighting enabled.

Examples

x = linspace(-2, 2, 50);
y = linspace(-2, 2, 50);
z = meshgrid(x, y);
surf(x, y, sin(x)' * cos(y));