MATLAB: MATLAB: save geospatial polygons in a *.kml file

kmlkmlwritemappingMapping Toolboxpolygons

After generating the poligons vertices and defined their faces, I've plotted the polygons with the patch function:
pp = patch('Faces',faces,'Vertices',vertices);
and then I've defined the patches colors:
set(pp,'FaceColor','flat',...
'FaceVertexCData',cdata,...
'CDataMapping','direct',...
'EdgeAlpha',.4,'EdgeColor','b')
Getting the following Matlab plot:
Now, I would like to visualize these polygons with Google Earth, but I don't know how.
I've tried the function kmlwrite, but I could pass to it only the polygons' vertices's coordinates, generating a kml file with all points and no polygon, as shown below:
The question is: wow can I write geospatial polygons (and their colors) into a .kml file with kmlwrite function?
Thanks

Best Answer

I've found the solution of my problem in the KML ToolBox:
< https://www.mathworks.com/matlabcentral/fileexchange/34694-kml-toolbox-v2-3 https://www.mathworks.com/matlabcentral/fileexchange/34694-kml-toolbox-v2-3>
in particular in the k.poly3 function.