I am not familiar with the extractIsosurface function or the Medical Imaging Toolbox the function is part of, so I can not provide any suggestions to make your method work.
However, I can offer a workaround method. Use this file from the FEX - stlwrite. I have renamed the function to stl_write() to not overload the built-in stlwrite() function, and so should you.
I have executed the code with the FEX submission and removed the file. (Copyrighted material
%% Input Parameters
unitcellsize = 5; % Cell size [mm]
length_x = 15; % Samplesize in x direction [mm]
length_y = 15; % Samplesize in y direction [mm]
length_z = 15; % Samplesize in z direction [mm]
step = 0.1; % To control the resolution [the smaller the better]
isovalue = 0.1;
%% Lactice Equation
%% This line is not needed
% syms x y z
f = @(x,y,z) cos((2.*pi.*x)./unitcellsize) + cos((2.*pi.*y)./unitcellsize) + cos((2.*pi.*z)./unitcellsize);
% ------------------ Sample Size -------------------
a = -length_x/2:step:length_x/2;
b = -length_y/2:step:length_y/2;
c = -length_z/2:step:length_z/2;
[X,Y,Z] = meshgrid(a,b,c);
%% Getting Coordinates
V = f(X,Y,Z);
co = isosurface(a,b,c,V,isovalue);
%Write the data to stl file
stl_write('test.stl', co);
%Read the stl file to visualize the output
TO = stlread('test.stl');
trimesh(TO)