"Publish" code with bugs

1 view (last 30 days)
Michael Allshouse
Michael Allshouse on 14 Sep 2023
Edited: dpb on 14 Sep 2023
I am trying to create PDFs from the code submitted by students regardless of the codes being correct or not. Previous versions of publish would output the PDF even if there were errors. Using R2023a, I am getting an "Error in publish" error that prevents the outputting of broken code. Is there a work around?
Ex.: trial_script.m
A = [1 2; 3];
Then run publish('trial_script.m').

Accepted Answer

dpb
dpb on 14 Sep 2023
Edited: dpb on 14 Sep 2023
writematrix("A = [1 2; 3];",'trial_script.m','FileType','text')
type trial_script.m
A = [1 2; 3];
publish('trial_script.m')
Error using vertcat Dimensions of arrays being concatenated are not consistent. Error in trial_script (line 1) A = [1 2; 3];
ans = '/users/mss.system.ZvcubV/html/trial_script.html'
While the errors show up, publish still output the default html file; but you said it failed for a pdf so let's try that...
publish('trial_script.m','pdf')
Error using vertcat Dimensions of arrays being concatenated are not consistent. Error in trial_script (line 1) A = [1 2; 3];
ans = '/users/mss.system.ZvcubV/html/trial_script.pdf'
Well, that says it created a pdf file...
d=dir(ans)
d = struct with fields:
name: 'trial_script.pdf' folder: '/users/mss.system.ZvcubV/html' date: '14-Sep-2023 21:05:37' bytes: 5940 isdir: 0 datenum: 7.3914e+05
What result differing from the above are you getting?
type(fullfile(d.folder,d.name))
%PDF-1.5 %âãÏÓ 11 0 obj 581 endobj 3 0 obj << /Length 11 0 R /Filter /FlateDecode >> stream xÚuUËnÛ0□¼ó+öh□□Ë%õ°□ôà i□ □êD@□qPØ□⨰äZR□ôﻤ^¤¤X0¤□®f□ËYû□.OߢXÂ!□K□!D□T¨¡□□m,ÌU□Ùu□□¿Ð□□äÙ¦□+□E□$ùb □à□A^□z¼ZBò»M+□:WJH□□7ey.áµÊ□#üMËú°«□□25□Iø□åiQeç¢□ó3ìÊr÷¯□}ªó□ç□ÒÓ□¾O´□Bq®5Xe□¡57%u%□õ□²□ê2Û□~U□2ûSÃvqÊ□□p»ì²□²SíÝÆi×H»fÝ®¹□>uÏì□□â*¦□m□□□?^÷§¬z!uoYý□ß×K@ÄEòm}½□BÀ□□Rí□É-Ü$lèµç6□□□î□àM□EºÝ□B□hO¹□rå□ú□ÛaÀÃ0R□Nú□'ð□□äJÉpEAÿ□³À□□  b·m{î¾RC□x□WlùîaCjH□½Ö□Ì□□AÀã8Â□æAß □A□y□²÷U□□□ø□µ>Ñ□UóÐ□aº□N□Z ï□□BÃ3î □hëë□8µªÁ(a□□¬$Ð□Uôù□9□à2ps¼1d<Õ`Ítãxº£□¤□□4ó□f.,ß□WNh□3G□6ç□y1hnjôý□□Ô□¶□)×□Ðvnÿl□;³ZÛTs¹□Ã□□ □?X□□»Î□□˲Õ□wgõ□£gÝðØ*\în□ÐÉÀ©Ní□«□:□□ûæüú¾ª~X¬□¬ãsíèiã□l6kQ□þ`Ú□¹ lþ□Ѧd endstream endobj 2 0 obj <</Type/Page /Parent 1 0 R /Resources <</Font<< /F0 7 0 R/F1 10 0 R >> /ProcSet[/PDF/Text/ImageC] >> /MediaBox [ 0 0 612 792 ] /CropBox [ 0 0 612 792 ] /BleedBox [ 0 0 612 792 ] /Group<</Type/Group/S/Transparency/CS/DeviceRGB>> /Contents[ 3 0 R] >> endobj 13 0 obj 82 endobj 12 0 obj << /Type /ObjStm /N 5 /First 27 /Length 13 0 R /Filter /FlateDecode >> stream xÚS0Q0P0U0¶P0S07S°P044Q°T045âµ±QÐwQ□V0□RÐ□□□RÈ+ÍÉQ072□0b¹ìì¸(Te@□*3s□bT□ «□□□H3Ó endstream endobj 16 0 obj 298 endobj 15 0 obj << /Length 16 0 R /Filter /FlateDecode >> stream xÚU□Mo□0□□ïù□>nÚ□Ï□□"¤©Ý$□ûк?□□Ó!□□□zàßÏ6¬Ó□XïkÇ~□□□□cãú□¢÷0Ú□ÎÐõ® 8□×`□Îxé□$)´½□7'Ñ□Æ□□¨û´L3□□ëFÐ:ú â4□□î□□□ø□¢·ÐbèÝ□□dOWï¿q@7C\×ÐbGC^□□5□BÄ=□¹ÏÅ#¤â□□:¶8yc1□wAÐi\ë*®□]û¿¤ªµáÜÙ/□□□□c□JïDîD¦"S□¹È□d!Ù□³ÅAä□dY²¤¨□Hòñ©VÄÅ/oÅë□Îd□□Ë□□'µÎe.)²47?□åÙ□Á□□ ä□□Ù½Ø□É4¦□*©□¹Bø¯ù□nû³×□h³òV²AÞ]ïðö□~ô¼+þÔ□□Ô□¬ endstream endobj 21 0 obj <</Filter[/Crypt] /Subtype /XML /Length 2774 /Type /Metadata >> stream <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/"> <xmp:CreateDate>2023-09-14T21:05:37+00:00</xmp:CreateDate> <xmp:ModifyDate>2023-09-14T21:05:37+00:00</xmp:ModifyDate> <dc:format>application/pdf</dc:format> <pdf:Producer>Antenna House PDF Output Library 7.2.1727</pdf:Producer> <xmp:CreatorTool>AH XSL Formatter V7.2 MR2 for Linux64 : 7.2.3.54813 (2021-12-13T09:43+09)</xmp:CreatorTool> <xmp:MetadataDate>2023-09-14T21:05:37+00:00</xmp:MetadataDate> </rdf:Description></rdf:RDF></x:xmpmeta> <?xpacket end="w"?> endstream endobj 17 0 obj << /Type /Catalog /Pages 1 0 R /Names 18 0 R /Lang (en) /Metadata 21 0 R >> endobj 24 0 obj 254 endobj 23 0 obj << /Type /ObjStm /N 4 /First 23 /Length 24 0 R /Filter /FlateDecode >> stream xÚ□□MKÃ@□E÷□ÿÃÝ□R□□7I□□BA□¡`KC "Ø.F3J@3a2□ûï□D÷Â[Ý{Ï□□□□%□bC□□It□ç□«¯½b□üP□Ç□Úfx□pÛÓÅc÷zì,ÈÛn½<□+Ô`□ w-þ² □#ø□^~§□4JÚVw□´ ~□ .B□R$□¯ÃxÉù­»□Ç□ºùo2«´□□·Ãóã□¥6_ÒZeð□□□□□À»«÷m7~o"dpi□□ë(¡□gßiiEbEaÍÓ, □<=/□¶2º□ßÔäí¬ê:□□□□□ª(q□m?Z§|5Ò\g!Å"vTmdß«□¬□□□□¾ý□ô□X□ endstream endobj 26 0 obj 354 endobj 25 0 obj << /Type /ObjStm /N 3 /First 18 /Length 26 0 R /Filter /FlateDecode >> stream xÚ□RÛjÃ0□}7ì□ô□Åqî□Pèee□m□m·>□>x©□□Ú¤Øîèþ~□Ól¬»0LìèHG□u□□□ □H"□1Äýèª(□/Þ□ ø´©□ãóã□ó&□□ñ□´□<ÀÇÍÑheØ`ÀþOZè½²½Y³□5ã×uÙ¬u]AQ°3¿□□□èÍF□U□ÊÂsnT¥­Ch½¢□|ª□uã­4□□□ßɳ□¡□/õÚm□□a□Àß+ ¾~?.F{□□□¦Ù□þÈó~□/I ñq□ÿ□±­F{□Ç□½□Yîÿ»³[□æ'¬eQ/□□³4□□ó□L□-□>¸Æ□®□Ìp¾Íc­q¸ Dâ□oº}□□□ÚR¡^y□□9□□□¥«íÙ¤0òõB□Öt'+ë□ □£Qs©÷D□{?¾-l□i]c□r¯.^Á­□;]□ëj§ð□>jÙ□□□´çNí□È1|­¼¬□PÝ{yj-ª@wy□Rh´ú endstream endobj 28 0 obj 104 endobj 27 0 obj << /Type /ObjStm /N 1 /First 6 /Length 28 0 R /Filter /FlateDecode >> stream xÚS02P0൱QÐ÷ÉÌÍ,)V□VÐÈLÉ555³4·455°46ÓD□1²07ÒT□åÒ÷KÌMÅ®ÜRÁ@EÜÐÜÈ@SÁ□SÜÒ□¨Þ□$Î□b□□!PÜ□C=Är□°x,□□□□□ê□+v endstream endobj 29 0 obj <</Type/XRef /Size 30 /Index[0 30] /Info 22 0 R/ID[<51a6d314a860c100ebddbe86b0d25c47><51a6d314a860c100ebddbe86b0d25c47>] /Root 17 0 R/W[1 2 1] /Filter /FlateDecode /Length 99 >> stream xÚ□˱ □@□DÑ?{'G□>□|B□¸□□ 2□AL□□ô@□nÃÌ□O□ÙÕ□ÿ ¢8□□□®□E0¶□,;K<Qºìô}□å å/*«{õ¦z3¡GßzR9ýÛÑk±□ o□ûq□ $   endstream endobj startxref 5606 %%EOF

More Answers (0)

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Tags

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!