Hi Ruixin,
Currently, the MATLAB Report Generator's PPT API does not support creating sections programmatically.
The team plans to add this functionality in the future releases.
Alternatively, as a workaround, you can add sections in your template presentation with maybe a single slide in each section, for e.g., a Section Header slide. Then generate your new presentation using this template presentation and add the new slides using the index number, which represents the position of this new slide in the generated presentation. See https://www.mathworks.com/help/rptgen/ug/mlreportgen.ppt.presentation.add.html
For example, create a template presentation, named input.pptx, with 2 sections where each section consists of a single section header slide, as shown below:
Now create your output presentation using this input presentation as shown below:
ppt = mlreportgen.ppt.Presentation("output.pptx", "input.pptx");
open(ppt);
sect1Slide = add(ppt,'Title and Content',2);
sect2Slide = add(ppt,'Title and Content',4);
close(ppt);
rptview(ppt);
The generated output presentation looks like:
Hope this helps!
Thanks,
Rahul