1. MATLAB Info Home
  2. Teaching
  3. Citrix
  4. Publishing
  5. Publishing 2
  6. Emailing
  7. Getting Started
  8. Plotting
  9. My Homepage
Publishing MATLAB files

Viewing the m-files through the browser does NOT work nicely with Microsoft IE. Use another browser like Mozilla Firefox or Safari instead.

If you're reading this page, it's probably because you've been asked to "publish" your script file in MATLAB. To do this, you must format your .m file (for example, NAMED examplefile.m) in a specific way and put it in a specific location on your G-drive.

Here's a list of what you need to do:

  1. On your G-drive, create a directory/folder "www" (if you haven't already done so).
  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 "ma402".
  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

Caution! 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. An example file named examplefile.m can be found at:

The published page can be seen at:

In order to get full credit, your directories and files must be named correctly and you must have links to your function file and the m-file (script file) that created the webpage, along with the appropriate text, plots, and such to answer the problems.

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

NOTE: 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 Directory" 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"

For more information on creating webpages, at the Technology Services webpage, go to: "Information for Students", Click on "Topic: Miscellaneous" so that the "Student Web Pages" link appears and click on that. Or just go here. There you can see some directions along with a document on creating a web page.

Instructor: Dr. Lisa Oberbroeckling
Office: 312 Knott Hall
Phone: 410-617-2516
Email: loberbro "at" loyola "dot" edu