MATLAB: How to generating surface without plotting

surf

I wonder if it's possible to create a surface by ''surf'' without plotting?
That means, I only want the surface data, but I don't want the figure.
Anyone has idea?
Thanks a lot and happy new year 🙂

Best Answer

Since it is a graphical object, you cannot create it without plotting somewhere. However, you can make the figure invisible so that it does not appear on screen
[x, y, z] = ellipsoid(3,3,5,1,0.5,0.5)
f = figure('Visible', 'off');
ax = axes(f);
s = surf(ax,x,y,z)
direction = [rand() rand() rand()];
rotate(s,direction,rand()*360)