Hello everyone! So I have a script code that I have to publish, it has about 100 lines of code with about 30 lines of local functions at the end of it. Within the 100 lines, there are multiple section breaks "%%" to seperate each "part" of the question I answered as a means for me to organize.
When publishing as a PDF, HTML, DOC, etc., I would like for the respective plots and disp text to appear immediately underneath the code section it belongs to within the same section
However in reality, the plots and disp text ALWAYS shows up at the very end of the PDF, right underneath the local functions section. I am unsure why my publishing option is doing this. I am using the %% correctly to indicate section breaks, AND I am using snapnow at the correct places to force MATLAB to publish the images.
I included a visual demonstration below of my issue (Purely for demonstrative purposes, the code itself is not supposed to work but to rather show the overall structure ).
disp('Yes this is correct')
disp('Yes this is also correct')
disp('Yes this is also also correct')
answer = function pretend(this, is, works)
The issue persists on multiple devices (windows desktop and apple laptop) on multiple versions I used (MATLAB 2021a & MATLAB2021b,). Thank you in advance to all who contribute!