If you try to export the mesh to an stl using another library like stlwrite it won't work so you must use the
'savestl' function that comes with iso2mesh. I was automatically prompted to download some executables from their github when attempting to use this function.
Simpleyadd the lines:
indElem = find(elem(:,5) == 5);
savestl(node(:, 1:3) elem(indElem,:), 'stl_test_file.stl')
To the near the end of meshByIso2mesh.m
Note that the indElem variable represents the indices of the elements for different material types which can be changed to reflect what you would like to make an stl of. For example changing this line 'indElem = find(elem(:,5) == 4); ' will extract just the bone mesh.
Software versions used: MATLAB R2020b, Roast 3.0, Windows 10.
Kind regards,
Jake