Search code examples
matlaboptimizationminimization

Energy landscape of infinity-norm in MATLAB


I have to plot the energy landscape (basically the surface) for the infinity-norm using MATLAB. In the case of the 2-norm I did the following:

[x, y] = meshgrid(-20:1:20);
z2 = sqrt(x.^2 + y.^2); % My function
L2 = surfc(x, y, z2); % Surface (the result)

The problem is that I do not know how to such a thing for the infinity-norm. Any suggestion?


Solution

  • I think this does what you wnat:

    [x, y] = meshgrid(-20:1:20);
    zinf = max(abs(x), abs(y)); % inifinity norm: max of abs of components
    Linf = surfc(x, y, zinf);
    

    enter image description here