Publishing MATLAB files for class

Updated January 2018

Microsoft IE does not view m-files properly. Use another browser like Chrome, Mozilla Firefox or Safari instead.

This page is for mainly for my students for publishing their MATLAB assignments and projects. To do this, you must

  1. Format your .m file (for example, exampleFile.m) in a specific way (general information on formatting your MATLAB code for publishing, go to Publishing 2)
  2. Put it in a specific location on your G-drive to be viewable by me.

Here's a list of what you need to do (THESE ARE MY DIRECTIONS FOR MY CLASS!):

  1. On your G-drive, look to see you have a directory/folder "www". If you don't have it, go to my page on creating webpages on the G-drive and also look at the Technology Services page on Student Personal Pages.
  2. Within the "www" directory/folder, create another directory/folder "loy#" (where # is your student ID number.) See below for how to create directories/folders within MATLAB
  3. Within that directory/folder, create another directory/folder that signifies the class. For example, create a directory named "ma302".
  4. Save your m-files (your script and any function files you need) in this directory/folder.
  5. Format your script file in such a way so that it "publishes" nicely (details below)
  6. Once it is saved, within the command window in MATLAB, type
    publish('exampleFile.m', 'html')
  7. You can view your webpage at
    (where username is YOUR LOYOLA USERNAME and the "#" in loy# is replaced by your student ID number as directed above).
  8. In order to get full credit, your directories and files must be named correctly, you must have links to your function file(s) if needed, along with the appropriate text, commands, plots, etc. to answer the problems. Every published file must have a link to its m-file, the website, and date/time published at the bottom. For example,
    %% Original m-file
    % < exampleFile.m>
    %% URL of published webpage
    % < exampleFile.html>
    %% Date/time published
    DateTimePublished = datestr(now)

image of caution symbol IMPORTANT: in order for your original m-file(s) to be "linkable" on your published webpage, you must create the m-file within the "www" directory/folder or any of its subdirectories/subfolders from here on known as the "www-structure". Also, you can copy the template file (by doing a "save as") directly to the appropriate directory/folder in the "www-structure". If you first work with your m-file in a different place on your G-drive and then copy it over to the "www-structure", it will not have the correct permissions to be viewable from your html page.

To format your script file, use the exampleFile.m file or another template file you may be given specific to that assignment or project. The example file named exampleFile.m can be found at:

The published page can be seen at:

Remember, these files are SCRIPT files with the comments formatted a special way. I am not going into details of the formatting (go to Publishing 2 page for more details and examples of this). Here are 2 examples of the same script but one is "publishable" and the other is an ordinary SCRIPT file:
Basic2DPlotExample2Web.m (publishable version)

Creating directories/folders within MATLAB

You can create the directories/folders within MATLAB if you're unsure of how to do it otherwise. To create a folder, in the "Current Folder" window (left of the command window if using the default view), click on the down-arrow to the right of the bluish circular icon and a pop-down list will appear in which you can select "New Folder" (click on images below to see screenshot).

Screen shot of MATLAB with the down-arrow in the right corner of the Current Folder window circled     Screen shot of MATLAB with the submenue containing New Folder selection circled